Move vk_allocator to common
This commit is contained in:
@@ -77,25 +77,6 @@ else()
|
||||
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/share/wivrn/assets SYMBOLIC)
|
||||
endif()
|
||||
|
||||
if(ANDROID OR Vulkan_VERSION VERSION_LESS 1.3.268)
|
||||
# The Vulkan headers in Android do not include the C++ headers, download them
|
||||
# Minimum version is 1.3.256
|
||||
set(VULKAN_VERSION "1.3.268.0")
|
||||
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz)
|
||||
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz SYMBOLIC)
|
||||
else()
|
||||
file(DOWNLOAD https://github.com/KhronosGroup/Vulkan-Headers/archive/vulkan-sdk-${VULKAN_VERSION}.tar.gz ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz
|
||||
EXPECTED_HASH SHA256=94993cbe2b1a604c0d5d9ea37a767e1aba4d771d2bfd4ddceefd66243095164f)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz DESTINATION ${CMAKE_BINARY_DIR})
|
||||
|
||||
target_include_directories(wivrn PRIVATE ${CMAKE_BINARY_DIR}/Vulkan-Headers-vulkan-sdk-${VULKAN_VERSION}/include)
|
||||
endif()
|
||||
|
||||
target_sources(wivrn PRIVATE
|
||||
${imgui_SOURCE_DIR}/imgui.cpp
|
||||
${imgui_SOURCE_DIR}/imgui_draw.cpp
|
||||
@@ -116,7 +97,6 @@ target_compile_definitions(wivrn PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
|
||||
|
||||
target_compile_features(wivrn PRIVATE cxx_std_20)
|
||||
target_compile_definitions(wivrn PRIVATE "XR_USE_TIMESPEC=1")
|
||||
target_compile_definitions(wivrn PRIVATE VULKAN_HPP_NO_STRUCT_CONSTRUCTORS VMA_VULKAN_VERSION=1001000)
|
||||
|
||||
set_target_properties(wivrn PROPERTIES CXX_VISIBILITY_PRESET hidden)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "scene.h"
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/check.h"
|
||||
#include "utils/files.h"
|
||||
#include "utils/named_thread.h"
|
||||
#include "xr/actionset.h"
|
||||
@@ -39,6 +38,8 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <vk_mem_alloc.h>
|
||||
#include "vk/check.h"
|
||||
#include "xr/check.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#include <vulkan/vulkan_handles.hpp>
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "scenes/stream.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/check.h"
|
||||
#include <cassert>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <hb-ft.h>
|
||||
#include <hb.h>
|
||||
|
||||
#include "utils/check.h"
|
||||
#include <vk_mem_alloc.h>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <vulkan/vulkan_enums.hpp>
|
||||
|
||||
@@ -19,37 +19,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <system_error>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <openxr/openxr.h>
|
||||
#include <system_error>
|
||||
|
||||
namespace xr
|
||||
{
|
||||
const std::error_category & error_category();
|
||||
}
|
||||
|
||||
namespace vk
|
||||
{
|
||||
const std::error_category & error_category();
|
||||
}
|
||||
|
||||
static inline VkResult check(VkResult result, const char * statement)
|
||||
{
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::system_error(result, vk::error_category(), statement);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VkResult check(VkResult result, const char * /*statement*/, const char * message)
|
||||
{
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::system_error(result, vk::error_category(), message);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline XrResult check(XrResult result, const char * statement)
|
||||
{
|
||||
if (!XR_SUCCEEDED(result))
|
||||
@@ -66,5 +43,4 @@ static inline XrResult check(XrResult result, const char * /*statement*/, const
|
||||
return result;
|
||||
}
|
||||
|
||||
#define CHECK_VK(result, ...) check(result, #result __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define CHECK_XR(result, ...) check(result, #result __VA_OPT__(, ) __VA_ARGS__)
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <jni.h>
|
||||
#endif
|
||||
|
||||
#include "utils/check.h"
|
||||
#include "utils/typename.h"
|
||||
#include "xr/check.h"
|
||||
#include <type_traits>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "utils/check.h"
|
||||
#include "xr/check.h"
|
||||
#include "xr.h"
|
||||
#include <system_error>
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "utils/check.h"
|
||||
#include "utils/handle.h"
|
||||
#include "xr/check.h"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -77,11 +77,7 @@ public:
|
||||
F get_proc(const char * name)
|
||||
{
|
||||
F f;
|
||||
XrResult result = xrGetInstanceProcAddr(id, name, (PFN_xrVoidFunction *)&f);
|
||||
if (!XR_SUCCEEDED(result))
|
||||
{
|
||||
throw std::system_error(result, vk::error_category(), std::string("xrGetInstanceProcAddr(") + name + ")");
|
||||
}
|
||||
CHECK_XR(xrGetInstanceProcAddr(id, name, (PFN_xrVoidFunction *)&f), name);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#include "system.h"
|
||||
|
||||
#include "details/enumerate.h"
|
||||
#include "xr.h"
|
||||
#include "vk/check.h"
|
||||
#include "xr/check.h"
|
||||
#include <cassert>
|
||||
#include <openxr/openxr_platform.h>
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
#include "session.h"
|
||||
#include "swapchain.h"
|
||||
#include "system.h"
|
||||
#include "utils/check.h"
|
||||
#include "xr/check.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
+27
-1
@@ -24,10 +24,36 @@ configure_file(wivrn_config.h.in wivrn_config.h)
|
||||
|
||||
add_library(wivrn-common STATIC
|
||||
wivrn_sockets.cpp
|
||||
vk/allocation.cpp
|
||||
vk/error_category.cpp
|
||||
vk/vk_allocator.cpp
|
||||
vk/vk_mem_alloc.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(wivrn-common PUBLIC Boost::pfr)
|
||||
if(ANDROID)
|
||||
# The Vulkan headers in Android do not include the C++ headers, download them
|
||||
# Minimum version is 1.3.256
|
||||
set(VULKAN_VERSION "1.3.268.0")
|
||||
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz)
|
||||
file(CREATE_LINK ${CMAKE_SOURCE_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz SYMBOLIC)
|
||||
else()
|
||||
file(DOWNLOAD https://github.com/KhronosGroup/Vulkan-Headers/archive/vulkan-sdk-${VULKAN_VERSION}.tar.gz ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz
|
||||
EXPECTED_HASH SHA256=94993cbe2b1a604c0d5d9ea37a767e1aba4d771d2bfd4ddceefd66243095164f)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/vulkan-sdk-${VULKAN_VERSION}.tar.gz DESTINATION ${CMAKE_BINARY_DIR})
|
||||
|
||||
target_include_directories(wivrn-common PUBLIC ${CMAKE_BINARY_DIR}/Vulkan-Headers-vulkan-sdk-${VULKAN_VERSION}/include)
|
||||
else()
|
||||
target_link_libraries(wivrn-common PUBLIC Vulkan::Headers)
|
||||
endif()
|
||||
|
||||
target_link_libraries(wivrn-common PUBLIC Boost::pfr wivrn-external)
|
||||
target_compile_features(wivrn-common PRIVATE cxx_std_20)
|
||||
target_compile_definitions(wivrn-common PUBLIC VULKAN_HPP_NO_STRUCT_CONSTRUCTORS VMA_VULKAN_VERSION=1001000)
|
||||
|
||||
target_include_directories(wivrn-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "allocation.h"
|
||||
|
||||
#include "utils/check.h"
|
||||
#include "vk/check.h"
|
||||
|
||||
#include "vulkan/vulkan_raii.hpp"
|
||||
#include <utility>
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 <system_error>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
const std::error_category & error_category();
|
||||
}
|
||||
|
||||
static inline VkResult check(VkResult result, const char * statement)
|
||||
{
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::system_error(result, vk::error_category(), statement);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline VkResult check(VkResult result, const char * /*statement*/, const char * message)
|
||||
{
|
||||
if (result != VK_SUCCESS)
|
||||
throw std::system_error(result, vk::error_category(), message);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define CHECK_VK(result, ...) check(result, #result __VA_OPT__(, ) __VA_ARGS__)
|
||||
@@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "utils/check.h"
|
||||
#include "vk/check.h"
|
||||
#include <system_error>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <vulkan/vulkan_to_string.hpp>
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "vk_allocator.h"
|
||||
#include "utils/check.h"
|
||||
#include "vk/check.h"
|
||||
|
||||
vk_allocator::vk_allocator(const VmaAllocatorCreateInfo & info)
|
||||
{
|
||||
Reference in New Issue
Block a user