Allow building without downloading libktx
This commit is contained in:
@@ -23,6 +23,7 @@ option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
|
|||||||
auto_option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" AUTO)
|
auto_option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" AUTO)
|
||||||
auto_option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" AUTO)
|
auto_option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" AUTO)
|
||||||
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd" AUTO)
|
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd" AUTO)
|
||||||
|
auto_option(WIVRN_USE_LIBKTX "Use libktx" AUTO)
|
||||||
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
|
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
|
||||||
option(WIVRN_BUILD_CLIENT "Build WiVRn client" OFF)
|
option(WIVRN_BUILD_CLIENT "Build WiVRn client" OFF)
|
||||||
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
|
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
|
||||||
@@ -195,6 +196,16 @@ if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
|
|||||||
find_program(RSVG_CONVERT rsvg-convert REQUIRED)
|
find_program(RSVG_CONVERT rsvg-convert REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIVRN_BUILD_CLIENT)
|
||||||
|
if (WIVRN_USE_LIBKTX STREQUAL "AUTO")
|
||||||
|
if (ANDROID)
|
||||||
|
set(WIVRN_USE_LIBKTX ON)
|
||||||
|
else()
|
||||||
|
set(WIVRN_USE_LIBKTX OFF)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
|
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
|
||||||
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
|
||||||
find_package(Fontconfig REQUIRED)
|
find_package(Fontconfig REQUIRED)
|
||||||
@@ -204,6 +215,7 @@ if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
|
|||||||
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
|
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
|
||||||
find_package(OpenXR 1.0.26 REQUIRED)
|
find_package(OpenXR 1.0.26 REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
|||||||
+11
-2
@@ -7,7 +7,11 @@ set(KTX_FEATURE_LOADTEST_APPS OFF)
|
|||||||
|
|
||||||
set(FASTGLTF_COMPILE_AS_CPP20 ON)
|
set(FASTGLTF_COMPILE_AS_CPP20 ON)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(simdjson spdlog glm fastgltf imgui stb libktx implot uni-algo)
|
FetchContent_MakeAvailable(simdjson spdlog glm fastgltf imgui stb implot uni-algo)
|
||||||
|
|
||||||
|
if (WIVRN_USE_LIBKTX)
|
||||||
|
FetchContent_MakeAvailable(libktx)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT BOOST_FOUND)
|
if (NOT BOOST_FOUND)
|
||||||
FetchContent_MakeAvailable(boost)
|
FetchContent_MakeAvailable(boost)
|
||||||
@@ -84,7 +88,12 @@ file(GLOB_RECURSE VULKAN_SHADERS CONFIGURE_DEPENDS "*.glsl")
|
|||||||
target_sources(wivrn PRIVATE ${LOCAL_SOURCE} ${VULKAN_SHADERS})
|
target_sources(wivrn PRIVATE ${LOCAL_SOURCE} ${VULKAN_SHADERS})
|
||||||
wivrn_compile_glsl(wivrn ${VULKAN_SHADERS})
|
wivrn_compile_glsl(wivrn ${VULKAN_SHADERS})
|
||||||
|
|
||||||
target_link_libraries(wivrn Vulkan::Vulkan spdlog::spdlog glm::glm fastgltf FreetypeHarfbuzz stb ktx_read Boost::locale)
|
target_link_libraries(wivrn Vulkan::Vulkan spdlog::spdlog glm::glm fastgltf FreetypeHarfbuzz stb Boost::locale)
|
||||||
|
|
||||||
|
if (WIVRN_USE_LIBKTX)
|
||||||
|
target_link_libraries(wivrn ktx_read)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(wivrn PRIVATE -DXR_USE_GRAPHICS_API_VULKAN)
|
target_compile_definitions(wivrn PRIVATE -DXR_USE_GRAPHICS_API_VULKAN)
|
||||||
target_compile_definitions(wivrn PRIVATE -DVMA_STATS_STRING_ENABLED=0)
|
target_compile_definitions(wivrn PRIVATE -DVMA_STATS_STRING_ENABLED=0)
|
||||||
target_compile_definitions(wivrn PRIVATE -DGLM_ENABLE_EXPERIMENTAL)
|
target_compile_definitions(wivrn PRIVATE -DGLM_ENABLE_EXPERIMENTAL)
|
||||||
|
|||||||
@@ -18,9 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "image_loader.h"
|
#include "image_loader.h"
|
||||||
|
#include "wivrn_config.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
#include <ktxvulkan.h>
|
#include <ktxvulkan.h>
|
||||||
|
#endif
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
@@ -48,6 +51,7 @@ struct image_resources
|
|||||||
vk::raii::ImageView image_view = nullptr;
|
vk::raii::ImageView image_view = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
struct ktx_image_resources
|
struct ktx_image_resources
|
||||||
{
|
{
|
||||||
ktxVulkanTexture ktx_texture;
|
ktxVulkanTexture ktx_texture;
|
||||||
@@ -63,6 +67,7 @@ struct ktx_image_resources
|
|||||||
ktxVulkanTexture_Destruct(&ktx_texture, device, nullptr);
|
ktxVulkanTexture_Destruct(&ktx_texture, device, nullptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr vk::Format formats[4] = {vk::Format::eUndefined, vk::Format::eUndefined, vk::Format::eUndefined, vk::Format::eUndefined};
|
constexpr vk::Format formats[4] = {vk::Format::eUndefined, vk::Format::eUndefined, vk::Format::eUndefined, vk::Format::eUndefined};
|
||||||
@@ -160,13 +165,17 @@ image_loader::image_loader(vk::raii::PhysicalDevice physical_device, vk::raii::D
|
|||||||
queue(queue),
|
queue(queue),
|
||||||
cb_pool(cb_pool)
|
cb_pool(cb_pool)
|
||||||
{
|
{
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
vdi = ktxVulkanDeviceInfo_Create(*physical_device, *device, *queue, *cb_pool, nullptr);
|
vdi = ktxVulkanDeviceInfo_Create(*physical_device, *device, *queue, *cb_pool, nullptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
image_loader::~image_loader()
|
image_loader::~image_loader()
|
||||||
{
|
{
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
if (vdi)
|
if (vdi)
|
||||||
ktxVulkanDeviceInfo_Destroy(vdi);
|
ktxVulkanDeviceInfo_Destroy(vdi);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::Format format)
|
void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::Format format)
|
||||||
@@ -397,6 +406,7 @@ void image_loader::do_load_raw(const void * pixels, vk::Extent3D extent, vk::For
|
|||||||
|
|
||||||
void image_loader::do_load_ktx(std::span<const std::byte> bytes)
|
void image_loader::do_load_ktx(std::span<const std::byte> bytes)
|
||||||
{
|
{
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
ktxTexture * texture;
|
ktxTexture * texture;
|
||||||
ktxVulkanTexture vk_texture;
|
ktxVulkanTexture vk_texture;
|
||||||
|
|
||||||
@@ -451,6 +461,9 @@ void image_loader::do_load_ktx(std::span<const std::byte> bytes)
|
|||||||
};
|
};
|
||||||
|
|
||||||
image_view = std::shared_ptr<vk::raii::ImageView>(r, &r->image_view);
|
image_view = std::shared_ptr<vk::raii::ImageView>(r, &r->image_view);
|
||||||
|
#else
|
||||||
|
throw std::runtime_error("Compiled without KTX support");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr bool starts_with(std::span<const std::byte> data, std::span<const uint8_t> prefix)
|
static constexpr bool starts_with(std::span<const std::byte> data, std::span<const uint8_t> prefix)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "vk/allocation.h"
|
#include "vk/allocation.h"
|
||||||
#include "vk/fwd.h"
|
#include "vk/fwd.h"
|
||||||
|
#include "wivrn_config.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <glm/vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
@@ -29,7 +30,9 @@
|
|||||||
#include <span>
|
#include <span>
|
||||||
#include <vulkan/vulkan.hpp>
|
#include <vulkan/vulkan.hpp>
|
||||||
|
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
struct ktxVulkanDeviceInfo;
|
struct ktxVulkanDeviceInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct image_loader
|
struct image_loader
|
||||||
{
|
{
|
||||||
@@ -71,7 +74,9 @@ struct image_loader
|
|||||||
~image_loader();
|
~image_loader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if WIVRN_USE_LIBKTX
|
||||||
ktxVulkanDeviceInfo * vdi = nullptr;
|
ktxVulkanDeviceInfo * vdi = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
vk::raii::Device & device;
|
vk::raii::Device & device;
|
||||||
vk::raii::Queue & queue;
|
vk::raii::Queue & queue;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <glm/vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
#include <glm/vec4.hpp>
|
#include <glm/vec4.hpp>
|
||||||
#include <ktxvulkan.h>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#cmakedefine01 WIVRN_SHOW_IMGUI_DEMO_WINDOW
|
#cmakedefine01 WIVRN_SHOW_IMGUI_DEMO_WINDOW
|
||||||
#cmakedefine01 WIVRN_CLIENT_DEBUG_MENU
|
#cmakedefine01 WIVRN_CLIENT_DEBUG_MENU
|
||||||
|
#cmakedefine01 WIVRN_USE_LIBKTX
|
||||||
|
|
||||||
#define WIVRN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
#define WIVRN_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
||||||
#define OPENCOMPOSITE_SEARCH_PATH "@OPENCOMPOSITE_SEARCH_PATH@"
|
#define OPENCOMPOSITE_SEARCH_PATH "@OPENCOMPOSITE_SEARCH_PATH@"
|
||||||
|
|||||||
Reference in New Issue
Block a user