Merge pull request #3911 from RichardTea/update_draco
Update Draco to upstream e4103dcpull/3918/head^2
commit
199aa5dd66
|
@ -1 +0,0 @@
|
|||
2.3.0
|
|
@ -1,31 +0,0 @@
|
|||
cache: ccache
|
||||
language: cpp
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: gcc
|
||||
- os: osx
|
||||
compiler: clang
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- cmake
|
||||
|
||||
script:
|
||||
# Output version info for compilers, cmake, and make
|
||||
- ${CC} -v
|
||||
- ${CXX} -v
|
||||
- cmake --version
|
||||
- make --version
|
||||
# Clone googletest
|
||||
- pushd .. && git clone https://github.com/google/googletest.git && popd
|
||||
# Configure and build
|
||||
- mkdir _travis_build && cd _travis_build
|
||||
- cmake -G "Unix Makefiles" -DENABLE_TESTS=ON ..
|
||||
- make -j10
|
||||
- ./draco_tests
|
|
@ -804,7 +804,7 @@ else()
|
|||
draco_points_enc)
|
||||
|
||||
# Library targets that consume the object collections.
|
||||
if(MSVC OR WIN32)
|
||||
if(MSVC)
|
||||
# In order to produce a DLL and import library the Windows tools require
|
||||
# that the exported symbols are part of the DLL target. The unfortunate side
|
||||
# effect of this is that a single configuration cannot output both the
|
||||
|
@ -889,9 +889,6 @@ else()
|
|||
# For Mac, we need to build a .bundle for the unity plugin.
|
||||
if(APPLE)
|
||||
set_target_properties(dracodec_unity PROPERTIES BUNDLE true)
|
||||
elseif(NOT unity_decoder_lib_type STREQUAL STATIC)
|
||||
set_target_properties(dracodec_unity
|
||||
PROPERTIES SOVERSION ${DRACO_SOVERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -916,9 +913,6 @@ else()
|
|||
# For Mac, we need to build a .bundle for the plugin.
|
||||
if(APPLE)
|
||||
set_target_properties(draco_maya_wrapper PROPERTIES BUNDLE true)
|
||||
else()
|
||||
set_target_properties(draco_maya_wrapper
|
||||
PROPERTIES SOVERSION ${DRACO_SOVERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
<img width="350px" src="docs/artwork/draco3d-vert.svg" />
|
||||
</p>
|
||||
|
||||
![Build Status: master](https://travis-ci.org/google/draco.svg?branch=master)
|
||||
[![Build Status](https://github.com/google/draco/workflows/Build/badge.svg)](https://github.com/google/draco/actions?query=workflow%3ABuild)
|
||||
|
||||
News
|
||||
=======
|
||||
### Version 1.4.1 release
|
||||
* Using the versioned gstatic.com WASM and Javascript decoders is now
|
||||
* Using the versioned www.gstatic.com WASM and Javascript decoders is now
|
||||
recommended. To use v1.4.1, use this URL:
|
||||
* https://www.gstatic.com/draco/versioned/decoders/1.4.1/*
|
||||
* Replace the * with the files to load. E.g.
|
||||
* https://gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js
|
||||
* https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js
|
||||
* This works with the v1.3.6 and v1.4.0 releases, and will work with future
|
||||
Draco releases.
|
||||
* Bug fixes
|
||||
|
|
|
@ -6,7 +6,7 @@ set(DRACO_CMAKE_DRACO_BUILD_DEFINITIONS_CMAKE_ 1)
|
|||
# Utility for controlling the main draco library dependency. This changes in
|
||||
# shared builds, and when an optional target requires a shared library build.
|
||||
macro(set_draco_target)
|
||||
if(MSVC OR WIN32)
|
||||
if(MSVC)
|
||||
set(draco_dependency draco)
|
||||
set(draco_plugin_dependency ${draco_dependency})
|
||||
else()
|
||||
|
@ -63,6 +63,11 @@ macro(draco_set_build_definitions)
|
|||
if(BUILD_SHARED_LIBS)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
endif()
|
||||
else()
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
# Ensure 64-bit platforms can support large files.
|
||||
list(APPEND draco_defines "_LARGEFILE_SOURCE" "_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
|
@ -114,4 +119,6 @@ macro(draco_set_build_definitions)
|
|||
draco_check_emscripten_environment()
|
||||
draco_get_required_emscripten_flags(FLAG_LIST_VAR draco_base_cxx_flags)
|
||||
endif()
|
||||
|
||||
draco_configure_sanitizer()
|
||||
endmacro()
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
if(DRACO_CMAKE_DRACO_FEATURES_CMAKE_)
|
||||
return()
|
||||
endif()
|
||||
set(DRACO_CMAKE_DRACO_FEATURES_CMAKE_ 1)
|
||||
|
||||
set(draco_features_file_name "${draco_build_dir}/draco/draco_features.h")
|
||||
set(draco_features_list)
|
||||
|
||||
# Macro that handles tracking of Draco preprocessor symbols for the purpose of
|
||||
# producing draco_features.h.
|
||||
#
|
||||
# draco_enable_feature(FEATURE <feature_name> [TARGETS <target_name>]) FEATURE
|
||||
# is required. It should be a Draco preprocessor symbol. TARGETS is optional. It
|
||||
# can be one or more draco targets.
|
||||
#
|
||||
# When the TARGETS argument is not present the preproc symbol is added to
|
||||
# draco_features.h. When it is draco_features.h is unchanged, and
|
||||
# target_compile_options() is called for each target specified.
|
||||
macro(draco_enable_feature)
|
||||
set(def_flags)
|
||||
set(def_single_arg_opts FEATURE)
|
||||
set(def_multi_arg_opts TARGETS)
|
||||
cmake_parse_arguments(DEF "${def_flags}" "${def_single_arg_opts}"
|
||||
"${def_multi_arg_opts}" ${ARGN})
|
||||
if("${DEF_FEATURE}" STREQUAL "")
|
||||
message(FATAL_ERROR "Empty FEATURE passed to draco_enable_feature().")
|
||||
endif()
|
||||
|
||||
# Do nothing/return early if $DEF_FEATURE is already in the list.
|
||||
list(FIND draco_features_list ${DEF_FEATURE} df_index)
|
||||
if(NOT df_index EQUAL -1)
|
||||
return()
|
||||
endif()
|
||||
|
||||
list(LENGTH DEF_TARGETS df_targets_list_length)
|
||||
if(${df_targets_list_length} EQUAL 0)
|
||||
list(APPEND draco_features_list ${DEF_FEATURE})
|
||||
else()
|
||||
foreach(target ${DEF_TARGETS})
|
||||
target_compile_definitions(${target} PRIVATE ${DEF_FEATURE})
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Function for generating draco_features.h.
|
||||
function(draco_generate_features_h)
|
||||
file(WRITE "${draco_features_file_name}.new"
|
||||
"// GENERATED FILE -- DO NOT EDIT\n\n" "#ifndef DRACO_FEATURES_H_\n"
|
||||
"#define DRACO_FEATURES_H_\n\n")
|
||||
|
||||
foreach(feature ${draco_features_list})
|
||||
file(APPEND "${draco_features_file_name}.new" "#define ${feature}\n")
|
||||
endforeach()
|
||||
|
||||
file(APPEND "${draco_features_file_name}.new"
|
||||
"\n#endif // DRACO_FEATURES_H_")
|
||||
|
||||
# Will replace ${draco_features_file_name} only if the file content has
|
||||
# changed. This prevents forced Draco rebuilds after CMake runs.
|
||||
configure_file("${draco_features_file_name}.new"
|
||||
"${draco_features_file_name}")
|
||||
file(REMOVE "${draco_features_file_name}.new")
|
||||
endfunction()
|
|
@ -80,6 +80,12 @@ macro(draco_test_cxx_flag)
|
|||
# Run the actual compile test.
|
||||
unset(draco_all_cxx_flags_pass CACHE)
|
||||
message("--- Running combined CXX flags test, flags: ${all_cxx_flags}")
|
||||
|
||||
# check_cxx_compiler_flag() requires that the flags are a string. When flags
|
||||
# are passed as a list it will remove the list separators, and attempt to run
|
||||
# a compile command using list entries concatenated together as a single
|
||||
# argument. Avoid the problem by forcing the argument to be a string.
|
||||
draco_set_and_stringify(SOURCE_VARS all_cxx_flags DEST all_cxx_flags)
|
||||
check_cxx_compiler_flag("${all_cxx_flags}" draco_all_cxx_flags_pass)
|
||||
|
||||
if(cxx_test_FLAG_REQUIRED AND NOT draco_all_cxx_flags_pass)
|
||||
|
@ -194,6 +200,9 @@ macro(draco_test_exe_linker_flag)
|
|||
else()
|
||||
unset(CMAKE_EXE_LINKER_FLAGS)
|
||||
endif()
|
||||
|
||||
list(APPEND DRACO_EXE_LINKER_FLAGS ${${link_FLAG_LIST_VAR_NAME}})
|
||||
list(REMOVE_DUPLICATES DRACO_EXE_LINKER_FLAGS)
|
||||
endmacro()
|
||||
|
||||
# Runs the draco compiler tests. This macro builds up the list of list var(s)
|
||||
|
|
|
@ -55,7 +55,7 @@ macro(draco_setup_install_target)
|
|||
install(TARGETS draco_encoder DESTINATION
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC)
|
||||
install(TARGETS draco DESTINATION
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
|
|
|
@ -5,28 +5,28 @@ set(DRACO_CMAKE_DRACO_SANITIZER_CMAKE_ 1)
|
|||
|
||||
# Handles the details of enabling sanitizers.
|
||||
macro(draco_configure_sanitizer)
|
||||
if(DRACO_SANITIZE AND NOT MSVC)
|
||||
if(DRACO_SANITIZE AND NOT EMSCRIPTEN AND NOT MSVC)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if(DRACO_SANITIZE MATCHES "cfi")
|
||||
list(APPEND DRACO_CXX_FLAGS "-flto" "-fno-sanitize-trap=cfi")
|
||||
list(APPEND DRACO_EXE_LINKER_FLAGS "-flto" "-fno-sanitize-trap=cfi"
|
||||
list(APPEND SAN_CXX_FLAGS "-flto" "-fno-sanitize-trap=cfi")
|
||||
list(APPEND SAN_LINKER_FLAGS "-flto" "-fno-sanitize-trap=cfi"
|
||||
"-fuse-ld=gold")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4
|
||||
AND DRACO_SANITIZE MATCHES "integer|undefined")
|
||||
list(APPEND DRACO_EXE_LINKER_FLAGS "--rtlib=compiler-rt" "-lgcc_s")
|
||||
list(APPEND SAN_LINKER_FLAGS "--rtlib=compiler-rt" "-lgcc_s")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND DRACO_CXX_FLAGS "-fsanitize=${DRACO_SANITIZE}")
|
||||
list(APPEND DRACO_EXE_LINKER_FLAGS "-fsanitize=${DRACO_SANITIZE}")
|
||||
list(APPEND SAN_CXX_FLAGS "-fsanitize=${DRACO_SANITIZE}")
|
||||
list(APPEND SAN_LINKER_FLAGS "-fsanitize=${DRACO_SANITIZE}")
|
||||
|
||||
# Make sanitizer callstacks accurate.
|
||||
list(APPEND DRACO_CXX_FLAGS "-fno-omit-frame-pointer"
|
||||
"-fno-optimize-sibling-calls")
|
||||
list(APPEND SAN_CXX_FLAGS "-fno-omit-frame-pointer")
|
||||
list(APPEND SAN_CXX_FLAGS "-fno-optimize-sibling-calls")
|
||||
|
||||
draco_test_cxx_flag(FLAG_LIST_VAR_NAMES DRACO_CXX_FLAGS FLAG_REQUIRED)
|
||||
draco_test_exe_linker_flag(FLAG_LIST_VAR_NAME DRACO_EXE_LINKER_FLAGS)
|
||||
draco_test_cxx_flag(FLAG_LIST_VAR_NAMES SAN_CXX_FLAGS FLAG_REQUIRED)
|
||||
draco_test_exe_linker_flag(FLAG_LIST_VAR_NAME SAN_LINKER_FLAGS)
|
||||
endif()
|
||||
endmacro()
|
||||
|
|
|
@ -87,6 +87,7 @@ macro(draco_add_executable)
|
|||
endif()
|
||||
|
||||
add_executable(${exe_NAME} ${exe_SOURCES})
|
||||
set_target_properties(${exe_NAME} PROPERTIES VERSION ${DRACO_VERSION})
|
||||
|
||||
if(exe_OUTPUT_NAME)
|
||||
set_target_properties(${exe_NAME} PROPERTIES OUTPUT_NAME ${exe_OUTPUT_NAME})
|
||||
|
@ -109,10 +110,11 @@ macro(draco_add_executable)
|
|||
|
||||
if(exe_LINK_FLAGS OR DRACO_EXE_LINKER_FLAGS)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.13")
|
||||
set(link_flags ${exe_LINK_FLAGS} ${DRACO_EXE_LINKER_FLAGS})
|
||||
list(APPEND exe_LINK_FLAGS "${DRACO_EXE_LINKER_FLAGS}")
|
||||
# LINK_FLAGS is managed as a string.
|
||||
draco_set_and_stringify(SOURCE "${exe_LINK_FLAGS}" DEST exe_LINK_FLAGS)
|
||||
set_target_properties(${exe_NAME}
|
||||
PROPERTIES LINK_FLAGS ${exe_LINK_FLAGS}
|
||||
${DRACO_EXE_LINKER_FLAGS})
|
||||
PROPERTIES LINK_FLAGS "${exe_LINK_FLAGS}")
|
||||
else()
|
||||
target_link_options(${exe_NAME} PRIVATE ${exe_LINK_FLAGS}
|
||||
${DRACO_EXE_LINKER_FLAGS})
|
||||
|
@ -130,7 +132,7 @@ macro(draco_add_executable)
|
|||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS AND (MSVC OR WIN32))
|
||||
target_compile_definitions(${lib_NAME} PRIVATE "DRACO_BUILDING_DLL=0")
|
||||
target_compile_definitions(${exe_NAME} PRIVATE "DRACO_BUILDING_DLL=0")
|
||||
endif()
|
||||
|
||||
if(exe_LIB_DEPS)
|
||||
|
@ -163,8 +165,8 @@ endmacro()
|
|||
# cmake-format: off
|
||||
# - OUTPUT_NAME: Override output file basename. Target basename defaults to
|
||||
# NAME. OUTPUT_NAME is ignored when BUILD_SHARED_LIBS is enabled and CMake
|
||||
# is generating a build for which MSVC or WIN32 are true. This is to avoid
|
||||
# output basename collisions with DLL import libraries.
|
||||
# is generating a build for which MSVC is true. This is to avoid output
|
||||
# basename collisions with DLL import libraries.
|
||||
# - TEST: Flag. Presence means treat library as a test.
|
||||
# - DEFINES: List of preprocessor macro definitions.
|
||||
# - INCLUDES: list of include directories for the target.
|
||||
|
@ -259,7 +261,7 @@ macro(draco_add_library)
|
|||
endif()
|
||||
|
||||
if(lib_OUTPUT_NAME)
|
||||
if(NOT (BUILD_SHARED_LIBS AND (MSVC OR WIN32)))
|
||||
if(NOT (BUILD_SHARED_LIBS AND MSVC))
|
||||
set_target_properties(${lib_NAME}
|
||||
PROPERTIES OUTPUT_NAME ${lib_OUTPUT_NAME})
|
||||
endif()
|
||||
|
@ -318,8 +320,12 @@ macro(draco_add_library)
|
|||
set_target_properties(${lib_NAME} PROPERTIES PREFIX "")
|
||||
endif()
|
||||
|
||||
if(lib_TYPE STREQUAL SHARED AND NOT MSVC)
|
||||
set_target_properties(${lib_NAME} PROPERTIES SOVERSION ${DRACO_SOVERSION})
|
||||
# VERSION and SOVERSION as necessary
|
||||
if(NOT lib_TYPE STREQUAL STATIC AND NOT lib_TYPE STREQUAL MODULE)
|
||||
set_target_properties(${lib_NAME} PROPERTIES VERSION ${DRACO_VERSION})
|
||||
if(NOT MSVC)
|
||||
set_target_properties(${lib_NAME} PROPERTIES SOVERSION ${DRACO_SOVERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS AND (MSVC OR WIN32))
|
||||
|
|
|
@ -17,31 +17,31 @@
|
|||
namespace draco {
|
||||
void DracoTimer::Start() {
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceCounter(&tv_start);
|
||||
QueryPerformanceCounter(&tv_start_);
|
||||
#else
|
||||
gettimeofday(&tv_start, nullptr);
|
||||
gettimeofday(&tv_start_, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DracoTimer::Stop() {
|
||||
#ifdef _WIN32
|
||||
QueryPerformanceCounter(&tv_end);
|
||||
QueryPerformanceCounter(&tv_end_);
|
||||
#else
|
||||
gettimeofday(&tv_end, nullptr);
|
||||
gettimeofday(&tv_end_, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t DracoTimer::GetInMs() {
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER elapsed = {0};
|
||||
elapsed.QuadPart = tv_end.QuadPart - tv_start.QuadPart;
|
||||
elapsed.QuadPart = tv_end_.QuadPart - tv_start_.QuadPart;
|
||||
|
||||
LARGE_INTEGER frequency = {0};
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
return elapsed.QuadPart * 1000 / frequency.QuadPart;
|
||||
#else
|
||||
const int64_t seconds = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
|
||||
const int64_t milliseconds = (tv_end.tv_usec - tv_start.tv_usec) / 1000;
|
||||
const int64_t seconds = (tv_end_.tv_sec - tv_start_.tv_sec) * 1000;
|
||||
const int64_t milliseconds = (tv_end_.tv_usec - tv_start_.tv_usec) / 1000;
|
||||
return seconds + milliseconds;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
typedef LARGE_INTEGER timeval;
|
||||
typedef LARGE_INTEGER DracoTimeVal;
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
typedef timeval DracoTimeVal;
|
||||
#endif
|
||||
|
||||
#include <cinttypes>
|
||||
|
@ -39,8 +40,8 @@ class DracoTimer {
|
|||
int64_t GetInMs();
|
||||
|
||||
private:
|
||||
timeval tv_start;
|
||||
timeval tv_end;
|
||||
DracoTimeVal tv_start_;
|
||||
DracoTimeVal tv_end_;
|
||||
};
|
||||
|
||||
typedef DracoTimer CycleTimer;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
|
||||
namespace draco {
|
||||
namespace parser {
|
||||
|
@ -252,7 +253,7 @@ DecoderBuffer ParseLineIntoDecoderBuffer(DecoderBuffer *buffer) {
|
|||
|
||||
std::string ToLower(const std::string &str) {
|
||||
std::string out;
|
||||
std::transform(str.begin(), str.end(), std::back_inserter(out), [](unsigned char c){return tolower(c);});
|
||||
std::transform(str.begin(), str.end(), std::back_inserter(out), tolower);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -268,14 +268,14 @@ std::vector<std::string> PlyReader::SplitWords(const std::string &line) {
|
|||
while ((end = line.find_first_of(" \t\n\v\f\r", start)) !=
|
||||
std::string::npos) {
|
||||
const std::string word(line.substr(start, end - start));
|
||||
if (!std::all_of(word.begin(), word.end(), [](unsigned char c){return isspace(c);})) {
|
||||
if (!std::all_of(word.begin(), word.end(), isspace)) {
|
||||
output.push_back(word);
|
||||
}
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
const std::string last_word(line.substr(start));
|
||||
if (!std::all_of(last_word.begin(), last_word.end(), [](unsigned char c){return isspace(c);})) {
|
||||
if (!std::all_of(last_word.begin(), last_word.end(), isspace)) {
|
||||
output.push_back(last_word);
|
||||
}
|
||||
return output;
|
||||
|
|
|
@ -87,7 +87,14 @@ size_t StdioFileReader::GetFileSize() {
|
|||
return false;
|
||||
}
|
||||
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
const size_t file_size = static_cast<size_t>(ftello(file_));
|
||||
#elif defined _WIN64
|
||||
const size_t file_size = static_cast<size_t>(_ftelli64(file_));
|
||||
#else
|
||||
const size_t file_size = static_cast<size_t>(ftell(file_));
|
||||
#endif
|
||||
|
||||
rewind(file_);
|
||||
|
||||
return file_size;
|
||||
|
|
Loading…
Reference in New Issue