diff --git a/CMakeLists.txt b/CMakeLists.txt index 4db6ed9a..368e4a48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,7 +165,8 @@ endif() # Common dependencies FetchContent_Declare(boostpfr URL https://github.com/boostorg/pfr/archive/refs/tags/2.2.0.tar.gz) # Client dependencies -FetchContent_Declare(fastgltf URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.6.1.tar.gz) +FetchContent_Declare(simdjson URL https://github.com/simdjson/simdjson/archive/refs/tags/v3.9.3.tar.gz) +FetchContent_Declare(fastgltf URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.7.1.tar.gz) FetchContent_Declare(glm URL https://github.com/g-truc/glm/archive/refs/tags/0.9.9.8.tar.gz) FetchContent_Declare(openxr_loader URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.0.34.tar.gz) FetchContent_Declare(spdlog URL https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6147b946..7f61e0e9 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -5,7 +5,9 @@ set(KTX_FEATURE_VK_UPLOAD ON) set(KTX_FEATURE_GL_UPLOAD OFF) set(KTX_FEATURE_LOADTEST_APPS OFF) -FetchContent_MakeAvailable(spdlog glm fastgltf imgui stb libktx implot) +set(FASTGLTF_COMPILE_AS_CPP20 ON) + +FetchContent_MakeAvailable(simdjson spdlog glm fastgltf imgui stb libktx implot) include(FreetypeHarfbuzz) include(CompileGLSL) @@ -121,7 +123,7 @@ file(GLOB_RECURSE VULKAN_SHADERS CONFIGURE_DEPENDS "*.glsl") target_sources(wivrn PRIVATE ${LOCAL_SOURCE} ${VULKAN_SHADERS}) wivrn_compile_glsl(wivrn ${VULKAN_SHADERS}) -target_link_libraries(wivrn Vulkan::Vulkan spdlog::spdlog glm::glm fastgltf FreetypeHarfbuzz stb fastgltf_simdjson ktx_read) +target_link_libraries(wivrn Vulkan::Vulkan spdlog::spdlog glm::glm fastgltf FreetypeHarfbuzz stb ktx_read) target_compile_definitions(wivrn PRIVATE -DXR_USE_GRAPHICS_API_VULKAN) target_compile_definitions(wivrn PRIVATE -DVMA_STATS_STRING_ENABLED=0) target_compile_options(wivrn PRIVATE -fdiagnostics-color -Wall -Wextra -pedantic) # -Werror @@ -133,7 +135,7 @@ target_compile_options(wivrn PRIVATE -Wno-missing-field-initializers -Wno-unused target_include_directories(wivrn PRIVATE .) -target_link_libraries(wivrn wivrn-common wivrn-external) +target_link_libraries(wivrn simdjson wivrn-common wivrn-external) if (CMAKE_BUILD_TYPE STREQUAL "Debug") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/vk_layer_settings.txt diff --git a/client/render/scene_data.cpp b/client/render/scene_data.cpp index d163b6c1..9040e830 100644 --- a/client/render/scene_data.cpp +++ b/client/render/scene_data.cpp @@ -25,8 +25,8 @@ #include "utils/ranges.h" #include #include +#include #include -#include #include #include #include @@ -142,21 +142,7 @@ fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::fi fastgltf::Options::LoadGLBBuffers | fastgltf::Options::DecomposeNodeMatrices; - fastgltf::Expected expected_asset{fastgltf::Error::None}; - - switch (fastgltf::determineGltfFileType(&buffer)) - { - case fastgltf::GltfType::GLB: - expected_asset = parser.loadBinaryGLTF(&buffer, directory, gltf_options); - break; - - case fastgltf::GltfType::glTF: - expected_asset = parser.loadGLTF(&buffer, directory, gltf_options); - break; - - case fastgltf::GltfType::Invalid: - throw std::runtime_error("Unrecognized file type"); - } + auto expected_asset = parser.loadGltf(&buffer, directory, gltf_options); if (auto error = expected_asset.error(); error != fastgltf::Error::None) throw std::runtime_error(std::string(fastgltf::getErrorMessage(error))); @@ -462,6 +448,10 @@ public: fastgltf::span data{reinterpret_cast(vector.bytes.data()), vector.bytes.size()}; return {data, vector.mimeType}; }, + [&](const fastgltf::sources::Array & array) -> return_type { + fastgltf::span data{reinterpret_cast(array.bytes.data()), array.bytes.size()}; + return {data, array.mimeType}; + }, [&](const fastgltf::sources::CustomBuffer & custom_buffer) -> return_type { throw std::runtime_error("Unimplemented source CustomBuffer"); // TODO ? @@ -724,7 +714,7 @@ public: unsorted_objects[child].parent_id = index; } - auto TRS = std::get(gltf_node.transform); + auto TRS = std::get(gltf_node.transform); unsorted_objects[index].position = glm::make_vec3(TRS.translation.data()); unsorted_objects[index].orientation = glm::make_quat(TRS.rotation.data());