Move client/src/* to client/*
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "buffer.h"
|
||||
#include "utils/check.h"
|
||||
|
||||
vk::buffer::buffer(VkDevice device, const VkBufferCreateInfo & create_info) :
|
||||
device(device)
|
||||
{
|
||||
CHECK_VK(vkCreateBuffer(device, &create_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::buffer::~buffer()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyBuffer(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class buffer : public utils::handle<VkBuffer>
|
||||
{
|
||||
VkDevice device{};
|
||||
|
||||
public:
|
||||
buffer() = default;
|
||||
buffer(VkDevice device, const VkBufferCreateInfo & create_info);
|
||||
buffer(const buffer &) = delete;
|
||||
buffer(buffer &&) = default;
|
||||
buffer & operator=(const buffer &) = delete;
|
||||
buffer & operator=(buffer &&) = default;
|
||||
~buffer();
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "buffer_view.h"
|
||||
#include "utils/check.h"
|
||||
|
||||
vk::buffer_view::buffer_view(VkDevice device, const VkBufferViewCreateInfo & create_info) :
|
||||
device(device)
|
||||
{
|
||||
CHECK_VK(vkCreateBufferView(device, &create_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::buffer_view::~buffer_view()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyBufferView(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class buffer_view : public utils::handle<VkBufferView>
|
||||
{
|
||||
VkDevice device{};
|
||||
|
||||
public:
|
||||
buffer_view() = default;
|
||||
buffer_view(VkDevice device, const VkBufferViewCreateInfo & create_info);
|
||||
buffer_view(const buffer_view &) = delete;
|
||||
buffer_view(buffer_view &&) = default;
|
||||
buffer_view & operator=(const buffer_view &) = delete;
|
||||
buffer_view & operator=(buffer_view &&) = default;
|
||||
~buffer_view();
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "command_pool.h"
|
||||
#include "vk.h"
|
||||
|
||||
vk::command_pool::command_pool(VkDevice device, uint32_t queueFamilyIndex) :
|
||||
device(device), lock(std::make_unique<std::mutex>())
|
||||
{
|
||||
VkCommandPoolCreateInfo cmdpool_create_info{};
|
||||
cmdpool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||
cmdpool_create_info.queueFamilyIndex = queueFamilyIndex;
|
||||
cmdpool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||
CHECK_VK(vkCreateCommandPool(device, &cmdpool_create_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::command_pool::~command_pool()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyCommandPool(device, id, nullptr);
|
||||
}
|
||||
|
||||
std::vector<VkCommandBuffer> vk::command_pool::allocate_command_buffers(uint32_t count, VkCommandBufferLevel level)
|
||||
{
|
||||
std::unique_lock _{*lock};
|
||||
|
||||
VkCommandBufferAllocateInfo alloc_info{};
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
alloc_info.commandPool = id;
|
||||
alloc_info.level = level;
|
||||
alloc_info.commandBufferCount = count;
|
||||
|
||||
std::vector<VkCommandBuffer> command_buffers{count};
|
||||
CHECK_VK(vkAllocateCommandBuffers(device, &alloc_info, command_buffers.data()));
|
||||
|
||||
return command_buffers;
|
||||
}
|
||||
|
||||
VkCommandBuffer vk::command_pool::allocate_command_buffer(VkCommandBufferLevel level)
|
||||
{
|
||||
std::unique_lock _{*lock};
|
||||
|
||||
VkCommandBufferAllocateInfo alloc_info{};
|
||||
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||
alloc_info.commandPool = id;
|
||||
alloc_info.level = level;
|
||||
alloc_info.commandBufferCount = 1;
|
||||
|
||||
VkCommandBuffer command_buffer;
|
||||
CHECK_VK(vkAllocateCommandBuffers(device, &alloc_info, &command_buffer));
|
||||
|
||||
return command_buffer;
|
||||
}
|
||||
|
||||
void vk::command_pool::free_command_buffers(const std::vector<VkCommandBuffer> & command_buffers)
|
||||
{
|
||||
std::unique_lock _{*lock};
|
||||
vkFreeCommandBuffers(device, id, command_buffers.size(), command_buffers.data());
|
||||
}
|
||||
|
||||
void vk::command_pool::free_command_buffer(VkCommandBuffer command_buffer)
|
||||
{
|
||||
if (command_buffer)
|
||||
{
|
||||
std::unique_lock _{*lock};
|
||||
vkFreeCommandBuffers(device, id, 1, &command_buffer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class command_pool : public utils::handle<VkCommandPool>
|
||||
{
|
||||
VkDevice device{};
|
||||
std::unique_ptr<std::mutex> lock;
|
||||
|
||||
public:
|
||||
command_pool() = default;
|
||||
command_pool(VkDevice device, uint32_t queueFamilyIndex);
|
||||
|
||||
command_pool(const command_pool &) = delete;
|
||||
command_pool(command_pool &&) = default;
|
||||
command_pool & operator=(const command_pool &) = delete;
|
||||
command_pool & operator=(command_pool &&) = default;
|
||||
~command_pool();
|
||||
|
||||
std::vector<VkCommandBuffer> allocate_command_buffers(uint32_t count, VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY);
|
||||
VkCommandBuffer allocate_command_buffer(VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY);
|
||||
|
||||
void free_command_buffers(const std::vector<VkCommandBuffer> & command_buffers);
|
||||
void free_command_buffer(VkCommandBuffer command_buffer);
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/typename.h"
|
||||
#include "vk/vk.h"
|
||||
#include <system_error>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk::details
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct structure_traits_base
|
||||
{
|
||||
static constexpr inline VkStructureType type = static_cast<VkStructureType>(-1);
|
||||
using base = T;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct structure_traits : structure_traits_base<T>
|
||||
{};
|
||||
|
||||
template <typename T>
|
||||
constexpr inline VkStructureType structure_type = structure_traits<T>::type;
|
||||
|
||||
template <typename T, typename F, typename... Args>
|
||||
auto enumerate(F f, Args &&... args) -> auto
|
||||
{
|
||||
std::vector<T> array;
|
||||
uint32_t count;
|
||||
VkResult result;
|
||||
|
||||
result = f(std::forward<Args>(args)..., &count, nullptr);
|
||||
|
||||
if (result >= 0)
|
||||
{
|
||||
if constexpr (structure_type<T> == static_cast<VkStructureType>(-1))
|
||||
{
|
||||
array.resize(count);
|
||||
}
|
||||
else
|
||||
{
|
||||
T default_value{};
|
||||
default_value.type = structure_type<T>;
|
||||
array.resize(count, default_value);
|
||||
}
|
||||
result = f(std::forward<Args>(args)..., &count, reinterpret_cast<typename structure_traits<T>::base *>(array.data()));
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
throw std::system_error(result, vk::error_category(), "enumerating " + type_name<T>());
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
} // namespace vk::details
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "device_memory.h"
|
||||
#include "utils/check.h"
|
||||
|
||||
uint32_t vk::device_memory::get_memory_type(VkPhysicalDevice physical_device, VkMemoryRequirements requirements, VkMemoryPropertyFlags property_flags)
|
||||
{
|
||||
uint32_t types = requirements.memoryTypeBits;
|
||||
|
||||
VkPhysicalDeviceMemoryProperties memory_properties{};
|
||||
vkGetPhysicalDeviceMemoryProperties(physical_device, &memory_properties);
|
||||
|
||||
for (uint32_t type = 0; type < memory_properties.memoryTypeCount; ++type)
|
||||
{
|
||||
if (not((1 << type) & types))
|
||||
continue;
|
||||
|
||||
const auto & properties = memory_properties.memoryTypes[type];
|
||||
if ((properties.propertyFlags & property_flags) == property_flags)
|
||||
return type;
|
||||
}
|
||||
|
||||
throw std::runtime_error{"No Vulkan memory with required flags"};
|
||||
}
|
||||
|
||||
vk::device_memory::device_memory(VkDevice device, const VkMemoryAllocateInfo & allocate_info) :
|
||||
device(device)
|
||||
{
|
||||
CHECK_VK(vkAllocateMemory(device, &allocate_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::device_memory::device_memory(VkDevice device, VkPhysicalDevice physical_device, VkImage target_image, VkMemoryPropertyFlags properties) :
|
||||
device(device)
|
||||
{
|
||||
VkMemoryRequirements requirements;
|
||||
vkGetImageMemoryRequirements(device, target_image, &requirements);
|
||||
|
||||
uint32_t memory_type = get_memory_type(physical_device, requirements, properties);
|
||||
|
||||
VkMemoryDedicatedAllocateInfoKHR dedicated_allocate_info{};
|
||||
dedicated_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
|
||||
dedicated_allocate_info.image = target_image;
|
||||
|
||||
VkMemoryAllocateInfo memory_allocate_info{};
|
||||
memory_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
memory_allocate_info.allocationSize = requirements.size;
|
||||
memory_allocate_info.memoryTypeIndex = memory_type;
|
||||
memory_allocate_info.pNext = &dedicated_allocate_info;
|
||||
|
||||
CHECK_VK(vkAllocateMemory(device, &memory_allocate_info, nullptr, &id));
|
||||
|
||||
try
|
||||
{
|
||||
CHECK_VK(vkBindImageMemory(device, target_image, id, 0));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
vkFreeMemory(device, id, nullptr);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
vk::device_memory::device_memory(VkDevice device, VkPhysicalDevice physical_device, VkBuffer target_buffer, VkMemoryPropertyFlags properties) :
|
||||
device(device)
|
||||
{
|
||||
VkMemoryRequirements requirements;
|
||||
vkGetBufferMemoryRequirements(device, target_buffer, &requirements);
|
||||
|
||||
uint32_t memory_type = get_memory_type(physical_device, requirements, properties);
|
||||
|
||||
VkMemoryDedicatedAllocateInfoKHR dedicated_allocate_info{};
|
||||
dedicated_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO;
|
||||
dedicated_allocate_info.buffer = target_buffer;
|
||||
|
||||
VkMemoryAllocateInfo memory_allocate_info{};
|
||||
memory_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
memory_allocate_info.allocationSize = requirements.size;
|
||||
memory_allocate_info.memoryTypeIndex = memory_type;
|
||||
memory_allocate_info.pNext = &dedicated_allocate_info;
|
||||
|
||||
CHECK_VK(vkAllocateMemory(device, &memory_allocate_info, nullptr, &id));
|
||||
|
||||
try
|
||||
{
|
||||
CHECK_VK(vkBindBufferMemory(device, target_buffer, id, 0));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
vkFreeMemory(device, id, nullptr);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
vk::device_memory::~device_memory()
|
||||
{
|
||||
if (device)
|
||||
{
|
||||
if (id and map)
|
||||
{
|
||||
vkUnmapMemory(device, id);
|
||||
}
|
||||
vkFreeMemory(device, id, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void vk::device_memory::map_memory()
|
||||
{
|
||||
CHECK_VK(vkMapMemory(device, id, 0, VK_WHOLE_SIZE, 0, (void **)&map));
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class device_memory : public utils::handle<VkDeviceMemory>
|
||||
{
|
||||
VkDevice device{};
|
||||
void * map = nullptr;
|
||||
|
||||
public:
|
||||
device_memory() = default;
|
||||
device_memory(VkDevice device, const VkMemoryAllocateInfo & allocate_info);
|
||||
device_memory(VkDevice device, VkPhysicalDevice physical_device, VkImage target_image, VkMemoryPropertyFlags properties);
|
||||
|
||||
device_memory(VkDevice device, VkPhysicalDevice physical_device, VkBuffer target_buffer, VkMemoryPropertyFlags properties);
|
||||
|
||||
device_memory(const device_memory &) = delete;
|
||||
device_memory(device_memory &&) = default;
|
||||
device_memory & operator=(const device_memory &) = delete;
|
||||
device_memory & operator=(device_memory &&) = default;
|
||||
~device_memory();
|
||||
|
||||
void * data()
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
void map_memory();
|
||||
|
||||
static uint32_t get_memory_type(VkPhysicalDevice physical_device, VkMemoryRequirements requirements, VkMemoryPropertyFlags property_flags);
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "utils/check.h"
|
||||
#include "vk.h"
|
||||
#include <system_error>
|
||||
|
||||
namespace
|
||||
{
|
||||
struct : std::error_category
|
||||
{
|
||||
const char * name() const noexcept override
|
||||
{
|
||||
return "vulkan";
|
||||
}
|
||||
|
||||
std::string message(int condition) const override
|
||||
{
|
||||
return string_VkResult(static_cast<VkResult>(condition));
|
||||
}
|
||||
} vulkan_error_category;
|
||||
} // namespace
|
||||
|
||||
const std::error_category & vk::error_category()
|
||||
{
|
||||
return vulkan_error_category;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "image.h"
|
||||
#include "utils/check.h"
|
||||
|
||||
vk::image::image(VkDevice device, const VkImageCreateInfo & create_info) :
|
||||
device(device)
|
||||
{
|
||||
CHECK_VK(vkCreateImage(device, &create_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::image::~image()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyImage(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class image : public utils::handle<VkImage>
|
||||
{
|
||||
VkDevice device{};
|
||||
|
||||
public:
|
||||
image() = default;
|
||||
image(VkDevice device, const VkImageCreateInfo & create_info);
|
||||
image(const image &) = delete;
|
||||
image(image &&) = default;
|
||||
image & operator=(const image &) = delete;
|
||||
image & operator=(image &&) = default;
|
||||
~image();
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pipeline.h"
|
||||
|
||||
#include "vk.h"
|
||||
|
||||
vk::pipeline::pipeline(VkDevice device, vk::pipeline::graphics_info & create_info, const VkPipelineLayout layout) :
|
||||
device(device)
|
||||
{
|
||||
for (VkPipelineShaderStageCreateInfo & i: create_info.shader_stages)
|
||||
{
|
||||
i.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||
}
|
||||
|
||||
create_info.InputAssemblyState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
create_info.RasterizationState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||
create_info.MultisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
create_info.DepthStencilState.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
||||
create_info.ColorBlendState.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo VertexInputState{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
.vertexBindingDescriptionCount = (uint32_t)create_info.vertex_input_bindings.size(),
|
||||
.pVertexBindingDescriptions = create_info.vertex_input_bindings.data(),
|
||||
.vertexAttributeDescriptionCount = (uint32_t)create_info.vertex_input_attributes.size(),
|
||||
.pVertexAttributeDescriptions = create_info.vertex_input_attributes.data(),
|
||||
};
|
||||
|
||||
VkPipelineDynamicStateCreateInfo DynamicState{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
|
||||
.dynamicStateCount = (uint32_t)create_info.dynamic_states.size(),
|
||||
.pDynamicStates = create_info.dynamic_states.data()};
|
||||
|
||||
VkPipelineViewportStateCreateInfo ViewportState{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
|
||||
.viewportCount = (uint32_t)create_info.viewports.size(),
|
||||
.pViewports = create_info.viewports.data(),
|
||||
.scissorCount = (uint32_t)create_info.scissors.size(),
|
||||
.pScissors = create_info.scissors.data(),
|
||||
};
|
||||
|
||||
VkGraphicsPipelineCreateInfo info{};
|
||||
info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
info.stageCount = create_info.shader_stages.size();
|
||||
info.pStages = create_info.shader_stages.data();
|
||||
info.pVertexInputState = &VertexInputState;
|
||||
info.pInputAssemblyState = &create_info.InputAssemblyState;
|
||||
info.pViewportState = &ViewportState;
|
||||
info.pRasterizationState = &create_info.RasterizationState;
|
||||
info.pMultisampleState = &create_info.MultisampleState;
|
||||
info.pColorBlendState = &create_info.ColorBlendState;
|
||||
info.layout = layout;
|
||||
info.renderPass = create_info.renderPass;
|
||||
info.subpass = create_info.subpass;
|
||||
|
||||
if (DynamicState.dynamicStateCount > 0)
|
||||
info.pDynamicState = &DynamicState;
|
||||
|
||||
CHECK_VK(vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::pipeline::~pipeline()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyPipeline(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "pipeline_layout.h"
|
||||
#include "utils/handle.h"
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class pipeline : public utils::handle<VkPipeline>
|
||||
{
|
||||
VkDevice device{};
|
||||
|
||||
public:
|
||||
struct graphics_info
|
||||
{
|
||||
std::vector<VkPipelineShaderStageCreateInfo> shader_stages;
|
||||
std::vector<VkVertexInputBindingDescription> vertex_input_bindings;
|
||||
std::vector<VkVertexInputAttributeDescription> vertex_input_attributes;
|
||||
VkPipelineInputAssemblyStateCreateInfo InputAssemblyState{};
|
||||
// VkPipelineTessellationStateCreateInfo TessellationState;
|
||||
std::vector<VkViewport> viewports;
|
||||
std::vector<VkRect2D> scissors;
|
||||
VkPipelineRasterizationStateCreateInfo RasterizationState{};
|
||||
VkPipelineMultisampleStateCreateInfo MultisampleState{};
|
||||
VkPipelineDepthStencilStateCreateInfo DepthStencilState{};
|
||||
VkPipelineColorBlendStateCreateInfo ColorBlendState{};
|
||||
std::vector<VkDynamicState> dynamic_states;
|
||||
VkRenderPass renderPass{};
|
||||
uint32_t subpass{};
|
||||
};
|
||||
|
||||
pipeline() = default;
|
||||
pipeline(VkDevice device, graphics_info & create_info, VkPipelineLayout layout);
|
||||
pipeline(const pipeline &) = delete;
|
||||
pipeline(pipeline &&) = default;
|
||||
pipeline & operator=(const pipeline &) = delete;
|
||||
pipeline & operator=(pipeline &&) = default;
|
||||
~pipeline();
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pipeline_layout.h"
|
||||
#include "utils/check.h"
|
||||
|
||||
vk::pipeline_layout::pipeline_layout(VkDevice device, const info & create_info) :
|
||||
device(device)
|
||||
{
|
||||
VkPipelineLayoutCreateInfo plci{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
.setLayoutCount = (uint32_t)create_info.descriptor_set_layouts.size(),
|
||||
.pSetLayouts = create_info.descriptor_set_layouts.data(),
|
||||
.pushConstantRangeCount = (uint32_t)create_info.push_constant_ranges.size(),
|
||||
.pPushConstantRanges = create_info.push_constant_ranges.data()};
|
||||
CHECK_VK(vkCreatePipelineLayout(device, &plci, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::pipeline_layout::~pipeline_layout()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyPipelineLayout(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class pipeline_layout : public utils::handle<VkPipelineLayout>
|
||||
{
|
||||
VkDevice device{};
|
||||
|
||||
public:
|
||||
struct info
|
||||
{
|
||||
std::vector<VkDescriptorSetLayout> descriptor_set_layouts;
|
||||
std::vector<VkPushConstantRange> push_constant_ranges;
|
||||
};
|
||||
|
||||
~pipeline_layout();
|
||||
pipeline_layout() = default;
|
||||
pipeline_layout(VkDevice device, const info & create_info);
|
||||
pipeline_layout(const pipeline_layout &) = delete;
|
||||
pipeline_layout(pipeline_layout &&) = default;
|
||||
pipeline_layout & operator=(const pipeline_layout &) = delete;
|
||||
pipeline_layout & operator=(pipeline_layout &&) = default;
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "renderpass.h"
|
||||
|
||||
#include "vk/vk.h"
|
||||
|
||||
vk::renderpass::renderpass(VkDevice device, info & create_info) :
|
||||
device(device)
|
||||
{
|
||||
VkRenderPassCreateInfo renderpass_create_info{};
|
||||
renderpass_create_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
renderpass_create_info.attachmentCount = create_info.attachments.size();
|
||||
renderpass_create_info.pAttachments = create_info.attachments.data();
|
||||
renderpass_create_info.subpassCount = create_info.subpasses.size();
|
||||
renderpass_create_info.pSubpasses = create_info.subpasses.data();
|
||||
renderpass_create_info.dependencyCount = create_info.dependencies.size();
|
||||
renderpass_create_info.pDependencies = create_info.dependencies.data();
|
||||
|
||||
CHECK_VK(vkCreateRenderPass(device, &renderpass_create_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::renderpass::~renderpass()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyRenderPass(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class renderpass : public utils::handle<VkRenderPass>
|
||||
{
|
||||
VkDevice device{};
|
||||
|
||||
public:
|
||||
struct info
|
||||
{
|
||||
std::vector<VkAttachmentDescription> attachments;
|
||||
std::vector<VkSubpassDescription> subpasses;
|
||||
std::vector<VkSubpassDependency> dependencies;
|
||||
};
|
||||
|
||||
renderpass() = default;
|
||||
renderpass(VkDevice device, info & create_info);
|
||||
renderpass(const renderpass &) = delete;
|
||||
renderpass(renderpass &&) = default;
|
||||
renderpass & operator=(const renderpass &) = delete;
|
||||
renderpass & operator=(renderpass &&) = default;
|
||||
~renderpass();
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "shader.h"
|
||||
|
||||
#include "vk.h"
|
||||
|
||||
vk::shader::shader(VkDevice device, const std::vector<uint32_t> & spirv) :
|
||||
device(device)
|
||||
{
|
||||
VkShaderModuleCreateInfo create_info{};
|
||||
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
create_info.pCode = data(spirv);
|
||||
create_info.codeSize = spirv.size() * sizeof(uint32_t);
|
||||
|
||||
CHECK_VK(vkCreateShaderModule(device, &create_info, nullptr, &id));
|
||||
}
|
||||
|
||||
vk::shader::shader(VkDevice device, const std::string & name) :
|
||||
shader(device, shaders.at(name)) {}
|
||||
|
||||
vk::shader::~shader()
|
||||
{
|
||||
if (device)
|
||||
vkDestroyShaderModule(device, id, nullptr);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/handle.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
extern const std::map<std::string, std::vector<uint32_t>> shaders;
|
||||
|
||||
namespace vk
|
||||
{
|
||||
class shader : public utils::handle<VkShaderModule>
|
||||
{
|
||||
VkDevice device;
|
||||
|
||||
public:
|
||||
shader(VkDevice device, const std::vector<uint32_t> & spirv);
|
||||
shader(VkDevice device, const std::string & name);
|
||||
shader(shader &&) = default;
|
||||
shader & operator=(shader &&) = default;
|
||||
shader(const shader &) = delete;
|
||||
shader operator=(const shader &) = delete;
|
||||
~shader();
|
||||
};
|
||||
} // namespace vk
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "external/magic_enum.hpp"
|
||||
#include "utils/check.h"
|
||||
#include "vk/buffer.h"
|
||||
#include "vk/buffer_view.h"
|
||||
#include "vk/command_pool.h"
|
||||
#include "vk/device_memory.h"
|
||||
#include "vk/image.h"
|
||||
#include "vk/pipeline.h"
|
||||
#include "vk/renderpass.h"
|
||||
#include "vk/shader.h"
|
||||
#include <string>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#if __has_include(<vulkan/vk_enum_string_helper.h>)
|
||||
#include <vulkan/vk_enum_string_helper.h>
|
||||
#else
|
||||
#define string_VkFormat(x) std::string(magic_enum::enum_name((VkFormat)(x)))
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct magic_enum::customize::enum_range<VkFormat>
|
||||
{
|
||||
static constexpr int min = 0;
|
||||
static constexpr int max = 200;
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
struct vk_chain
|
||||
{
|
||||
std::tuple<Args...> structs;
|
||||
};
|
||||
Reference in New Issue
Block a user