Update fastgltf to 0.7.1, add explicit simdjson dependency

Co-authored-by: Patrick Nicolas <patricknicolas@laposte.net>
This commit is contained in:
Guillaume Meunier
2024-06-02 17:50:05 +02:00
co-authored by Patrick Nicolas
parent 3e12d405b6
commit 006a633c0d
3 changed files with 14 additions and 21 deletions
+2 -1
View File
@@ -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)
+5 -3
View File
@@ -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
+7 -17
View File
@@ -25,8 +25,8 @@
#include "utils/ranges.h"
#include <boost/pfr/core.hpp>
#include <fastgltf/base64.hpp>
#include <fastgltf/core.hpp>
#include <fastgltf/glm_element_traits.hpp>
#include <fastgltf/parser.hpp>
#include <fastgltf/tools.hpp>
#include <fastgltf/types.hpp>
#include <fastgltf/util.hpp>
@@ -142,21 +142,7 @@ fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::fi
fastgltf::Options::LoadGLBBuffers |
fastgltf::Options::DecomposeNodeMatrices;
fastgltf::Expected<fastgltf::Asset> 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<const std::byte> data{reinterpret_cast<const std::byte *>(vector.bytes.data()), vector.bytes.size()};
return {data, vector.mimeType};
},
[&](const fastgltf::sources::Array & array) -> return_type {
fastgltf::span<const std::byte> data{reinterpret_cast<const std::byte *>(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<fastgltf::Node::TRS>(gltf_node.transform);
auto TRS = std::get<fastgltf::TRS>(gltf_node.transform);
unsorted_objects[index].position = glm::make_vec3(TRS.translation.data());
unsorted_objects[index].orientation = glm::make_quat(TRS.rotation.data());