Merge Changes for support of apple silicon on macOS

Mac Arm
master
Andrey Kleshchev 2025-09-03 20:30:12 +03:00 committed by GitHub
commit 90aa693f2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
188 changed files with 2289 additions and 3227 deletions

View File

@ -64,7 +64,7 @@ jobs:
# autobuild-package.xml.
AUTOBUILD_VCS_INFO: "true"
AUTOBUILD_VSVER: "170"
DEVELOPER_DIR: "/Applications/Xcode_16.1.app/Contents/Developer"
DEVELOPER_DIR: "/Applications/Xcode_16.4.app/Contents/Developer"
# Ensure that Linden viewer builds engage Bugsplat.
BUGSPLAT_DB: ${{ needs.setup.outputs.bugsplat_db }}
build_coverity: false
@ -98,7 +98,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: secondlife/build-variables
ref: master
ref: universal
path: .build-variables
- name: Checkout master-message-template

View File

@ -23,4 +23,4 @@ jobs:
path-to-signatures: signatures.json
remote-organization-name: secondlife
remote-repository-name: cla-signatures
allowlist: callum@mbp.localdomain,rye@lindenlab.com
allowlist: callum@mbp.localdomain,rye@lindenlab.com,rye

1
.gitignore vendored
View File

@ -26,7 +26,6 @@ debian/files
debian/secondlife-appearance-utility*
debian/secondlife-viewer*
indra/.distcc
indra/cmake/*
indra/out/*
indra/packages/*

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,7 @@ retry_cmd()
build_dir_Darwin()
{
echo build-darwin-x86_64
echo build-darwin-universal
}
build_dir_Linux()
@ -158,6 +158,7 @@ pre_build()
if [[ "$arch" == "Darwin" ]]
then
HAVOK=OFF
SIGNING=("-DENABLE_SIGNING:BOOL=YES" \
"-DSIGNING_IDENTITY:STRING=Developer ID Application: Linden Research, Inc.")
fi
@ -387,7 +388,7 @@ do
if `cat "$build_dir/build_ok"`
then
case "$variant" in
Release)
Release*)
if [ -r "$build_dir/autobuild-package.xml" ]
then
begin_section "Autobuild metadata"

View File

@ -10,7 +10,9 @@
## Nicky: Ideally we want at least 3.21 for good preset support
## We're not there yet, but once done, there is a kludge in Linking.cmake
# "if(${CMAKE_VERSION} VERSION_LESS "3.20.0")" that can also be removed
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.16.0...4.0 FATAL_ERROR)
cmake_policy(SET CMP0156 NEW)
cmake_policy(SET CMP0179 NEW)
set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING
"The root project/makefile/solution name. Defaults to SecondLife.")
@ -33,6 +35,14 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF) # This slows down build massively
set(CMAKE_OPTIMIZE_DEPENDENCIES ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
# Speeds up cmake generation significantly in some cases
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)
include(Variables)
include(BuildVersion)

View File

@ -78,6 +78,8 @@ if (WINDOWS)
NOMINMAX
# DOM_DYNAMIC # For shared library colladadom
_CRT_SECURE_NO_WARNINGS # Allow use of sprintf etc
_CRT_NONSTDC_NO_DEPRECATE # Allow use of sprintf etc
_CRT_OBSOLETE_NO_WARNINGS
_WINSOCK_DEPRECATED_NO_WARNINGS # Disable deprecated WinSock API warnings
)
add_compile_options(
@ -160,46 +162,40 @@ if (LINUX)
set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
endif (LINUX)
if (DARWIN)
# Use rpath loading on macos
set(CMAKE_MACOSX_RPATH TRUE)
# Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default
set(CLANG_DISABLE_FATAL_WARNINGS OFF)
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
set(DARWIN_extra_cstar_flags "-Wno-unused-local-typedef -Wno-deprecated-declarations")
# Ensure that CMAKE_CXX_FLAGS has the correct -g debug information format --
# see Variables.cmake.
string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}"
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DARWIN_extra_cstar_flags}")
# NOTE: it's critical that the optimization flag is put in front.
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
## Really?? On developer machines too?
##set(ENABLE_SIGNING TRUE)
##set(SIGNING_IDENTITY "Developer ID Application: Linden Research, Inc.")
# required for clang-15/xcode-15 since our boost package still uses deprecated std::unary_function/binary_function
# see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#C++-Standard-Library
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
endif (DARWIN)
# Ensure debug symbols are always generated
add_compile_options(-g --debug) # --debug is a clang synonym for -g that bypasses cmake behaviors
# Silence GL deprecation warnings
add_compile_definitions(GL_SILENCE_DEPRECATION=1)
endif(DARWIN)
if (LINUX OR DARWIN)
set(GCC_WARNINGS -Wall -Wno-sign-compare -Wno-trigraphs)
add_compile_options(-Wall -Wno-sign-compare -Wno-trigraphs -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable)
if (NOT GCC_DISABLE_FATAL_WARNINGS)
list(APPEND GCC_WARNINGS -Werror)
endif (NOT GCC_DISABLE_FATAL_WARNINGS)
list(APPEND GCC_WARNINGS -Wno-reorder -Wno-non-virtual-dtor )
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
list(APPEND GCC_WARNINGS -Wno-unused-but-set-variable -Wno-unused-variable )
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# libstdc++ headers contain deprecated declarations that fail on clang
# macOS currently has many deprecated calls
add_compile_options(-Wno-unused-local-typedef)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wno-stringop-truncation -Wno-parentheses -Wno-maybe-uninitialized)
endif()
if (NOT GCC_DISABLE_FATAL_WARNINGS AND NOT CLANG_DISABLE_FATAL_WARNINGS)
add_compile_options(-Werror)
endif ()
add_compile_options(${GCC_WARNINGS})
add_compile_options(-m${ADDRESS_SIZE})
endif (LINUX OR DARWIN)

View File

@ -9,35 +9,25 @@ use_system_binary( apr apr-util )
use_prebuilt_binary(apr_suite)
if (WINDOWS)
if (LLCOMMON_LINK_SHARED)
set(APR_selector "lib")
else (LLCOMMON_LINK_SHARED)
set(APR_selector "")
endif (LLCOMMON_LINK_SHARED)
target_link_libraries( ll::apr INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/${APR_selector}apr-1.lib
${ARCH_PREBUILT_DIRS_RELEASE}/${APR_selector}aprutil-1.lib
)
target_compile_definitions( ll::apr INTERFACE APR_DECLARE_STATIC=1 APU_DECLARE_STATIC=1 API_DECLARE_STATIC=1)
elseif (DARWIN)
if (LLCOMMON_LINK_SHARED)
set(APR_selector "0.dylib")
set(APRUTIL_selector "0.dylib")
else (LLCOMMON_LINK_SHARED)
set(APR_selector "a")
set(APRUTIL_selector "a")
endif (LLCOMMON_LINK_SHARED)
target_link_libraries( ll::apr INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.${APR_selector}
${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.${APR_selector}
iconv
)
else()
target_link_libraries( ll::apr INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.a
${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.a
rt
)
target_compile_definitions(ll::apr INTERFACE APR_DECLARE_STATIC=1 APU_DECLARE_STATIC=1 API_DECLARE_STATIC=1)
endif ()
target_include_directories( ll::apr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/apr-1 )
find_library(APR_LIBRARY
NAMES
apr-1.lib
libapr-1.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(APRUTIL_LIBRARY
NAMES
aprutil-1.lib
libaprutil-1.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::apr INTERFACE ${APR_LIBRARY} ${APRUTIL_LIBRARY})
if(DARWIN)
target_link_libraries(ll::apr INTERFACE iconv)
endif()
target_include_directories(ll::apr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/apr-1)

View File

@ -9,23 +9,29 @@ use_system_binary(vorbis)
use_prebuilt_binary(ogg_vorbis)
target_include_directories( ll::vorbis SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include )
if (WINDOWS)
target_link_libraries(ll::vorbis INTERFACE
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libogg.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libogg.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisenc.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbisenc.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisfile.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbisfile.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbis.lib
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbis.lib
)
else (WINDOWS)
target_link_libraries(ll::vorbis INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libogg.a
${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisenc.a
${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisfile.a
${ARCH_PREBUILT_DIRS_RELEASE}/libvorbis.a
)
endif (WINDOWS)
find_library(OGG_LIBRARY
NAMES
libogg.lib
libogg.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VORBIS_LIBRARY
NAMES
libvorbis.lib
libvorbis.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VORBISENC_LIBRARY
NAMES
libvorbisenc.lib
libvorbisenc.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VORBISFILE_LIBRARY
NAMES
libvorbisfile.lib
libvorbisfile.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::vorbis INTERFACE ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY} )

View File

@ -16,41 +16,65 @@ use_prebuilt_binary(boost)
# with the address size.
set(addrsfx "-x${ADDRESS_SIZE}")
if (WINDOWS)
target_link_libraries( ll::boost INTERFACE
libboost_context-mt${addrsfx}
libboost_fiber-mt${addrsfx}
libboost_filesystem-mt${addrsfx}
libboost_program_options-mt${addrsfx}
libboost_regex-mt${addrsfx}
libboost_system-mt${addrsfx}
libboost_thread-mt${addrsfx}
libboost_url-mt${addrsfx})
elseif (LINUX)
target_link_libraries( ll::boost INTERFACE
boost_context-mt${addrsfx}
boost_fiber-mt${addrsfx}
boost_filesystem-mt${addrsfx}
boost_program_options-mt${addrsfx}
boost_regex-mt${addrsfx}
boost_signals-mt${addrsfx}
boost_system-mt${addrsfx}
boost_thread-mt${addrsfx}
boost_url-mt${addrsfx})
elseif (DARWIN)
target_link_libraries( ll::boost INTERFACE
boost_context-mt${addrsfx}
boost_fiber-mt${addrsfx}
boost_filesystem-mt${addrsfx}
boost_program_options-mt${addrsfx}
boost_regex-mt${addrsfx}
boost_system-mt${addrsfx}
boost_thread-mt${addrsfx}
boost_url-mt${addrsfx})
endif (WINDOWS)
find_library(BOOST_CONTEXT_LIBRARY
NAMES
boost_context-mt
boost_context-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_FIBER_LIBRARY
NAMES
boost_fiber-mt
boost_fiber-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_FILESYSTEM_LIBRARY
NAMES
boost_filesystem-mt
boost_filesystem-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_PROGRAMOPTIONS_LIBRARY
NAMES
boost_program_options-mt
boost_program_options-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_REGEX_LIBRARY
NAMES
boost_regex-mt
boost_regex-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_SYSTEM_LIBRARY
NAMES
boost_system-mt
boost_system-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_THREAD_LIBRARY
NAMES
boost_thread-mt
boost_thread-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(BOOST_URL_LIBRARY
NAMES
boost_url-mt
boost_url-mt${addrsfx}
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::boost INTERFACE
${BOOST_FIBER_LIBRARY}
${BOOST_CONTEXT_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_PROGRAMOPTIONS_LIBRARY}
${BOOST_REGEX_LIBRARY}
${BOOST_SYSTEM_LIBRARY}
${BOOST_THREAD_LIBRARY}
${BOOST_URL_LIBRARY})
if (LINUX)
set(BOOST_SYSTEM_LIBRARY ${BOOST_SYSTEM_LIBRARY} rt)
set(BOOST_THREAD_LIBRARY ${BOOST_THREAD_LIBRARY} rt)
target_link_libraries(ll::boost INTERFACE rt)
endif (LINUX)

View File

@ -29,7 +29,6 @@ elseif (DARWIN)
${ARCH_PREBUILT_DIRS_RELEASE}/libcef_dll_wrapper.a
${ARCH_PREBUILT_DIRS_RELEASE}/libdullahan.a
${APPKIT_LIBRARY}
"-F ${CEF_LIBRARY}"
)
elseif (LINUX)

View File

@ -53,9 +53,11 @@ set(cmake_SOURCE_FILES
Prebuilt.cmake
PulseAudio.cmake
Python.cmake
SSE2NEON.cmake
TemplateCheck.cmake
TinyEXR.cmake
TinyGLTF.cmake
Tracy.cmake
Tut.cmake
UI.cmake
UnixInstall.cmake

View File

@ -7,19 +7,13 @@ add_library( ll::libcurl INTERFACE IMPORTED )
use_system_binary(libcurl)
use_prebuilt_binary(curl)
if (WINDOWS)
target_link_libraries(ll::libcurl INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libcurl.lib
ll::openssl
ll::nghttp2
ll::zlib-ng
)
else ()
target_link_libraries(ll::libcurl INTERFACE
${ARCH_PREBUILT_DIRS_RELEASE}/libcurl.a
ll::openssl
ll::nghttp2
ll::zlib-ng
)
endif ()
find_library(CURL_LIBRARY
NAMES
libcurl.lib
libcurl.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libcurl INTERFACE ${CURL_LIBRARY} ll::openssl ll::nghttp2 ll::zlib-ng)
target_include_directories( ll::libcurl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -59,11 +59,6 @@ if(WINDOWS)
openjp2.dll
)
if(LLCOMMON_LINK_SHARED)
set(release_files ${release_files} libapr-1.dll)
set(release_files ${release_files} libaprutil-1.dll)
endif()
# Filenames are different for 32/64 bit BugSplat file and we don't
# have any control over them so need to branch.
if (USE_BUGSPLAT)
@ -178,15 +173,6 @@ elseif(DARWIN)
libndofdev.dylib
)
if(LLCOMMON_LINK_SHARED)
set(release_files ${release_files}
libapr-1.0.dylib
libapr-1.dylib
libaprutil-1.0.dylib
libaprutil-1.dylib
)
endif()
if (TARGET ll::discord_sdk)
list(APPEND release_files libdiscord_partner_sdk.dylib)
endif ()
@ -236,13 +222,6 @@ elseif(LINUX)
libgmodule-2.0.so
libgobject-2.0.so
)
if(LLCOMMON_LINK_SHARED)
set(release_files ${release_files}
libapr-1.so.0
libaprutil-1.so.0
)
endif()
endif()
else(WINDOWS)

View File

@ -2,18 +2,21 @@
include(Prebuilt)
include_guard()
add_library( ll::expat INTERFACE IMPORTED )
add_library(ll::expat INTERFACE IMPORTED)
use_system_binary(expat)
use_prebuilt_binary(expat)
if (WINDOWS)
target_compile_definitions( ll::expat INTERFACE XML_STATIC=1)
target_link_libraries( ll::expat INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libexpatd.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.lib)
else ()
target_link_libraries( ll::expat INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libexpat.a
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.a)
target_compile_definitions(ll::expat INTERFACE XML_STATIC=1)
endif ()
target_include_directories( ll::expat SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include )
find_library(EXPAT_LIBRARY
NAMES
libexpat.lib
libexpat.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::expat INTERFACE ${EXPAT_LIBRARY})
target_include_directories(ll::expat SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -9,9 +9,10 @@ use_system_binary(freetype)
use_prebuilt_binary(freetype)
target_include_directories( ll::freetype SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/freetype2/)
if (WINDOWS)
target_link_libraries( ll::freetype INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/freetype.lib)
else()
target_link_libraries( ll::freetype INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libfreetype.a)
endif()
find_library(FREETYPE_LIBRARY
NAMES
freetype.lib
libfreetype.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::freetype INTERFACE ${FREETYPE_LIBRARY})

View File

@ -8,17 +8,17 @@ use_prebuilt_binary(dictionaries)
add_library( ll::hunspell INTERFACE IMPORTED )
use_system_binary(hunspell)
use_prebuilt_binary(libhunspell)
if (WINDOWS)
target_compile_definitions( ll::hunspell INTERFACE HUNSPELL_STATIC=1)
target_link_libraries( ll::hunspell INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/libhunspell.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell.lib
)
elseif(DARWIN)
target_link_libraries( ll::hunspell INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell-1.7.a
)
elseif(LINUX)
target_link_libraries( ll::hunspell INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell-1.7.a
)
endif()
find_library(HUNSPELL_LIBRARY
NAMES
libhunspell.lib
libhunspell-1.7.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::hunspell INTERFACE ${HUNSPELL_LIBRARY})
target_include_directories( ll::hunspell SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/hunspell)

View File

@ -8,13 +8,13 @@ add_library( ll::libjpeg INTERFACE IMPORTED )
use_system_binary(libjpeg)
use_prebuilt_binary(libjpeg-turbo)
if (LINUX)
target_link_libraries( ll::libjpeg INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a)
elseif (DARWIN)
target_link_libraries( ll::libjpeg INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a)
elseif (WINDOWS)
target_link_libraries( ll::libjpeg INTERFACE
debug ${ARCH_PREBUILT_DIRS_DEBUG}/jpeg.lib
optimized ${ARCH_PREBUILT_DIRS_RELEASE}/jpeg.lib)
endif (LINUX)
target_include_directories( ll::libjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)
find_library(JPEG_LIBRARY
NAMES
jpeg.lib
libjpeg.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libjpeg INTERFACE ${JPEG_LIBRARY})
target_include_directories(ll::libjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -92,6 +92,13 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
target_include_directories (PROJECT_${project}_TEST_${name} PRIVATE ${LIBS_OPEN_DIR}/test )
set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}")
if (DARWIN)
set_target_properties(PROJECT_${project}_TEST_${name}
PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH "@executable_path/Resources"
)
endif(DARWIN)
#
# Per-codefile additional / external project dep and lib dep property extraction
@ -225,7 +232,10 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
# test binaries always need to be signed for local development
set_target_properties(INTEGRATION_TEST_${testname}
PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-")
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
BUILD_WITH_INSTALL_RPATH 1
INSTALL_RPATH "@executable_path/Resources"
)
endif ()
# Add link deps to the executable

View File

@ -13,14 +13,17 @@ add_library( ll::kdu INTERFACE IMPORTED )
if (USE_KDU)
include(Prebuilt)
use_prebuilt_binary(kdu)
if (WINDOWS)
target_link_libraries( ll::kdu INTERFACE kdu.lib)
else (WINDOWS)
target_link_libraries( ll::kdu INTERFACE libkdu.a)
endif (WINDOWS)
find_library(KDU_LIBRARY
NAMES
kdu
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::kdu INTERFACE ${KDU_LIBRARY})
target_include_directories( ll::kdu SYSTEM INTERFACE
${AUTOBUILD_INSTALL_DIR}/include/kdu
${LIBS_OPEN_DIR}/llkdu
)
target_compile_definitions(ll::kdu INTERFACE KDU_NO_THREADS=1)
endif (USE_KDU)

View File

@ -24,26 +24,35 @@ use_prebuilt_binary(colladadom)
use_prebuilt_binary(minizip-ng) # needed for colladadom
use_prebuilt_binary(libxml2)
if (WINDOWS)
target_link_libraries( ll::minizip-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/minizip.lib )
else()
target_link_libraries( ll::minizip-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libminizip.a )
endif()
find_library(MINIZIPNG_LIBRARY
NAMES
minizip.lib
libminizip.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::minizip-ng INTERFACE ${MINIZIPNG_LIBRARY})
find_library(LIBXML2_LIBRARY
NAMES
libxml2.lib
libxml2.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libxml INTERFACE ${LIBXML2_LIBRARY})
if (WINDOWS)
target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.lib Bcrypt.lib)
else()
target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.a)
target_link_libraries( ll::libxml INTERFACE Bcrypt.lib)
endif()
target_include_directories( ll::colladadom SYSTEM INTERFACE
${LIBS_PREBUILT_DIR}/include/collada
${LIBS_PREBUILT_DIR}/include/collada/1.4
)
if (WINDOWS)
target_link_libraries(ll::colladadom INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libcollada14dom23-s.lib ll::libxml ll::minizip-ng )
elseif (DARWIN)
target_link_libraries(ll::colladadom INTERFACE collada14dom ll::boost ll::libxml ll::minizip-ng)
elseif (LINUX)
target_link_libraries(ll::colladadom INTERFACE collada14dom ll::boost ll::libxml ll::minizip-ng)
endif()
find_library(COLLADADOM_LIBRARY
NAMES
libcollada14dom23-s.lib
collada14dom
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::colladadom INTERFACE ${COLLADADOM_LIBRARY} ll::boost ll::libxml ll::minizip-ng)

View File

@ -9,20 +9,16 @@ use_prebuilt_binary(vlc-bin)
set(LIBVLCPLUGIN ON CACHE BOOL
"LIBVLCPLUGIN support for the llplugin/llmedia test apps.")
if (WINDOWS)
target_link_libraries( ll::libvlc INTERFACE
libvlc.lib
libvlccore.lib
)
elseif (DARWIN)
target_link_libraries( ll::libvlc INTERFACE
libvlc.dylib
libvlccore.dylib
)
elseif (LINUX)
# Specify a full path to make sure we get a static link
target_link_libraries( ll::libvlc INTERFACE
${LIBS_PREBUILT_DIR}/lib/libvlc.a
${LIBS_PREBUILT_DIR}/lib/libvlccore.a
)
endif (WINDOWS)
find_library(VLC_LIBRARY
NAMES
libvlc.lib
libvlc.dylib
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(VLCCORE_LIBRARY
NAMES
libvlccore.lib
libvlccore.dylib
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libvlc INTERFACE ${VLC_LIBRARY} ${VLCCORE_LIBRARY})

View File

@ -38,9 +38,10 @@ endif ()
# windows) and CMAKE_BUILD_TYPE on Makefile based generators (like linux). The reason for this is
# that CMAKE_BUILD_TYPE is essentially meaningless at configuration time for IDE generators and
# CMAKE_CFG_INTDIR is meaningless at build time for Makefile generators
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/$<LOWER_CASE:$<CONFIG>>)
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/release)
if(NOT DARWIN)
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/$<LOWER_CASE:$<CONFIG>>)
link_directories(${AUTOBUILD_INSTALL_DIR}/lib/release)
endif(NOT DARWIN)
add_library( ll::oslibraries INTERFACE IMPORTED )
@ -74,6 +75,8 @@ else()
find_library(APPKIT_LIBRARY AppKit)
find_library(COREAUDIO_LIBRARY CoreAudio)
find_library(COREGRAPHICS_LIBRARY CoreGraphics)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
target_link_libraries( ll::oslibraries INTERFACE
${COCOA_LIBRARY}
@ -82,6 +85,8 @@ else()
${CARBON_LIBRARY}
${APPKIT_LIBRARY}
${COREAUDIO_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${COREGRAPHICS_LIBRARY}
)
endif()

View File

@ -9,12 +9,12 @@ add_library( ll::meshoptimizer INTERFACE IMPORTED )
use_system_binary(meshoptimizer)
use_prebuilt_binary(meshoptimizer)
if (WINDOWS)
target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer.lib)
elseif (LINUX)
target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer.o)
elseif (DARWIN)
target_link_libraries( ll::meshoptimizer INTERFACE libmeshoptimizer.a)
endif (WINDOWS)
find_library(MESHOPTIMIZER_LIBRARY
NAMES
meshoptimizer.lib
libmeshoptimizer.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer)
target_link_libraries(ll::meshoptimizer INTERFACE ${MESHOPTIMIZER_LIBRARY})
target_include_directories(ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer)

View File

@ -13,12 +13,15 @@ if (NDOF)
use_prebuilt_binary(open-libndofdev)
endif (WINDOWS OR DARWIN)
if (WINDOWS)
target_link_libraries( ll::ndof INTERFACE libndofdev)
elseif (DARWIN OR LINUX)
target_link_libraries( ll::ndof INTERFACE ndofdev)
endif (WINDOWS)
target_compile_definitions( ll::ndof INTERFACE LIB_NDOF=1)
find_library(NDOF_LIBRARY
NAMES
libndofdev
ndofdev
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::ndof INTERFACE ${NDOF_LIBRARY})
target_compile_definitions(ll::ndof INTERFACE LIB_NDOF=1)
endif (NDOF)

View File

@ -6,9 +6,12 @@ add_library( ll::nghttp2 INTERFACE IMPORTED )
use_system_binary(nghttp2)
use_prebuilt_binary(nghttp2)
if (WINDOWS)
target_link_libraries( ll::nghttp2 INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/nghttp2.lib)
else ()
target_link_libraries( ll::nghttp2 INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libnghttp2.a)
endif ()
find_library(NGHTTP2_LIBRARY
NAMES
nghttp2.lib
libnghttp2.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::nghttp2 INTERFACE ${NGHTTP2_LIBRARY})
target_include_directories( ll::nghttp2 SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/nghttp2)

View File

@ -8,7 +8,7 @@ include_guard()
# to have memory leaks, has no option to play music streams
# It probably makes sense to to completely remove it
set(USE_OPENAL OFF CACHE BOOL "Enable OpenAL")
set(USE_OPENAL ON CACHE BOOL "Enable OpenAL")
# ND: To streamline arguments passed, switch from OPENAL to USE_OPENAL
# To not break all old build scripts convert old arguments but warn about it
if(OPENAL)
@ -22,20 +22,21 @@ if (USE_OPENAL)
target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1)
use_prebuilt_binary(openal)
if(WINDOWS)
target_link_libraries( ll::openal INTERFACE
OpenAL32
alut
)
elseif(LINUX)
target_link_libraries( ll::openal INTERFACE
openal
alut
)
else()
target_link_libraries( ll::openal INTERFACE
openal
alut
)
endif()
find_library(OPENAL_LIBRARY
NAMES
OpenAL32
openal
libopenal.dylib
libopenal.so
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(ALUT_LIBRARY
NAMES
alut
libalut.dylib
libalut.so
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::openal INTERFACE ${OPENAL_LIBRARY} ${ALUT_LIBRARY})
endif ()

View File

@ -1,11 +1,22 @@
# -*- cmake -*-
include(Prebuilt)
include_guard()
include(Prebuilt)
include(Linking)
add_library( ll::openjpeg INTERFACE IMPORTED )
use_system_binary(openjpeg)
use_prebuilt_binary(openjpeg)
target_link_libraries(ll::openjpeg INTERFACE openjp2 )
target_include_directories( ll::openjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/openjpeg)
find_library(OPENJPEG_LIBRARY
NAMES
openjp2
openjp2.lib
libopenjp2.a
libopenjp2.so
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::openjpeg INTERFACE ${OPENJPEG_LIBRARY})
target_include_directories(ll::openjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/openjpeg)

View File

@ -7,12 +7,24 @@ add_library( ll::openssl INTERFACE IMPORTED )
use_system_binary(openssl)
use_prebuilt_binary(openssl)
if (WINDOWS)
target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.lib ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.lib Crypt32.lib)
elseif (LINUX)
target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.a ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.a dl)
else()
target_link_libraries(ll::openssl INTERFACE ssl crypto)
endif (WINDOWS)
target_include_directories( ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)
find_library(SSL_LIBRARY
NAMES
libssl.lib
libssl.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
find_library(CRYPTO_LIBRARY
NAMES
libcrypto.lib
libcrypto.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::openssl INTERFACE ${SSL_LIBRARY} ${CRYPTO_LIBRARY})
if (WINDOWS)
target_link_libraries(ll::openssl INTERFACE Crypt32.lib)
endif (WINDOWS)
target_include_directories(ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)

View File

@ -6,9 +6,12 @@ add_library( ll::libpng INTERFACE IMPORTED )
use_system_binary(libpng)
use_prebuilt_binary(libpng)
if (WINDOWS)
target_link_libraries(ll::libpng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libpng16.lib)
else()
target_link_libraries(ll::libpng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libpng16.a)
endif()
target_include_directories( ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16)
find_library(LIBPNG_LIBRARY
NAMES
libpng16.lib
libpng16.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::libpng INTERFACE ${LIBPNG_LIBRARY})
target_include_directories(ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16)

View File

@ -1,5 +1,7 @@
# -*- cmake -*-
include(OpenGL)
add_library( ll::pluginlibraries INTERFACE IMPORTED )
if (WINDOWS)
@ -13,4 +15,6 @@ if (WINDOWS)
)
endif (WINDOWS)
target_link_libraries( ll::pluginlibraries INTERFACE OpenGL::GL)
target_include_directories( ll::pluginlibraries INTERFACE ${CMAKE_SOURCE_DIR}/llimage ${CMAKE_SOURCE_DIR}/llrender)

View File

@ -0,0 +1,12 @@
# -*- cmake -*-
include(Prebuilt)
add_library(ll::sse2neon INTERFACE IMPORTED)
if (DARWIN)
use_system_binary(sse2neon)
use_prebuilt_binary(sse2neon)
target_include_directories( ll::sse2neon SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/sse2neon)
endif()

View File

@ -15,6 +15,7 @@ endif()
if (USE_TRACY)
option(USE_TRACY_ON_DEMAND "Use on-demand Tracy profiling." ON)
option(USE_TRACY_LOCAL_ONLY "Disallow remote Tracy profiling." OFF)
option(USE_TRACY_GPU "Use Tracy GPU profiling" OFF)
use_system_binary(tracy)
use_prebuilt_binary(tracy)
@ -31,9 +32,8 @@ if (USE_TRACY)
target_compile_definitions(ll::tracy INTERFACE -DTRACY_NO_BROADCAST=1 -DTRACY_ONLY_LOCALHOST=1)
endif ()
# GHA runners don't always provide invariant TSC support, but always build with LL_TESTS enabled
if (DARWIN AND LL_TESTS)
target_compile_definitions(ll::tracy INTERFACE -DTRACY_TIMER_FALLBACK=1)
if (USE_TRACY_GPU AND NOT DARWIN) # Tracy OpenGL mode is incompatible with macOS/iOS
target_compile_definitions(ll::tracy INTERFACE -DLL_PROFILER_ENABLE_TRACY_OPENGL=1)
endif ()
# See: indra/llcommon/llprofiler.h

View File

@ -147,49 +147,29 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = '${CMAKE_OSX_DEPLOYMENT_TARGET}'")
string(REGEX MATCH "-stdlib=([^ ]+)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY = '${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY}'")
string(REGEX MATCH " -g([^ ]*)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "${CMAKE_MATCH_1}")
# -gdwarf-2 is passed in LL_BUILD according to 00-COMPILE-LINK-RUN.txt.
# However, when CMake 3.9.2 sees -gdwarf-2, it silently deletes the whole -g
# switch, producing no symbols at all! The same thing happens if we specify
# plain -g ourselves, i.e. CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT is
# the empty string. Specifying -gdwarf-with-dsym or just -gdwarf drives a
# different CMake behavior: it substitutes plain -g. As of 2017-09-19,
# viewer-build-variables/variables still passes -gdwarf-2, which is the
# no-symbols case. Set -gdwarf, triggering CMake to substitute plain -g --
# at least that way we should get symbols, albeit mangled ones. It Would Be
# Nice if CMake's behavior could be predicted from a consistent mental
# model, instead of only observed experimentally.
string(REPLACE "dwarf-2" "dwarf"
CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT
"${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT = '${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}'")
# Use dwarf symbols for most libraries for compilation speed
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'")
# allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var
set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
if ("${sysroot_idx}" LESS 0)
message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
endif ()
math(EXPR sysroot_idx "${sysroot_idx} + 1")
list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
endif()
message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
# set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
# if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
# string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
# list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
# if ("${sysroot_idx}" LESS 0)
# message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
# endif ()
# math(EXPR sysroot_idx "${sysroot_idx} + 1")
# list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
# endif()
# message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS ssse3)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.2)
# we must hard code this to off for now. xcode's built in signing does not
# handle embedded app bundles such as CEF and others. Any signing for local
# development must be done after the build as we do in viewer_manifest.py for
@ -204,9 +184,9 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "")
set(CMAKE_XCODE_ATTRIBUTE_DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING YES)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
set(CMAKE_OSX_ARCHITECTURES "${ARCH}")
string(REPLACE "i686" "i386" CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
string(REPLACE "AMD64" "x86_64" CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}")
if(NOT DEFINED CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
endif()
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Default deploy grid

View File

@ -1,32 +1,24 @@
# -*- cmake -*-
include_guard()
include(Linking)
include(Prebuilt)
include_guard()
add_library( ll::webrtc INTERFACE IMPORTED )
target_include_directories( ll::webrtc SYSTEM INTERFACE "${LIBS_PREBUILT_DIR}/include/webrtc" "${LIBS_PREBUILT_DIR}/include/webrtc/third_party/abseil-cpp")
use_prebuilt_binary(webrtc)
if (WINDOWS)
target_link_libraries( ll::webrtc INTERFACE webrtc.lib )
elseif (DARWIN)
FIND_LIBRARY(COREAUDIO_LIBRARY CoreAudio)
FIND_LIBRARY(COREGRAPHICS_LIBRARY CoreGraphics)
FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox)
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
find_library(WEBRTC_LIBRARY
NAMES
webrtc
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries( ll::webrtc INTERFACE
libwebrtc.a
${COREAUDIO_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${COREGRAPHICS_LIBRARY}
${COREFOUNDATION_LIBRARY}
${COCOA_LIBRARY}
)
target_link_libraries( ll::webrtc INTERFACE ${WEBRTC_LIBRARY} )
if (DARWIN)
target_link_libraries( ll::webrtc INTERFACE ll::oslibraries )
elseif (LINUX)
target_link_libraries( ll::webrtc INTERFACE libwebrtc.a X11 )
endif (WINDOWS)
target_link_libraries( ll::webrtc INTERFACE X11 )
endif ()

View File

@ -11,11 +11,14 @@ if(USE_CONAN )
endif()
use_prebuilt_binary(zlib-ng)
if (WINDOWS)
target_link_libraries( ll::zlib-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/zlib.lib )
else()
target_link_libraries( ll::zlib-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libz.a )
endif (WINDOWS)
find_library(ZLIBNG_LIBRARY
NAMES
zlib.lib
libz.a
PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH)
target_link_libraries(ll::zlib-ng INTERFACE ${ZLIBNG_LIBRARY})
if( NOT LINUX )
target_include_directories( ll::zlib-ng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/zlib-ng)

View File

@ -1,8 +1,5 @@
# -*- cmake -*-
if (XXHASH_CMAKE_INCLUDED)
return()
endif (XXHASH_CMAKE_INCLUDED)
set (XXHASH_CMAKE_INCLUDED TRUE)
include_guard()
include(Prebuilt)
use_prebuilt_binary(xxhash)

View File

@ -1,13 +1,5 @@
# -*- cmake -*-
set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING
"The root project/makefile/solution name. Defaults to SecondLife.")
project(${ROOT_PROJECT_NAME})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(Variables)
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)

View File

@ -1,8 +1,3 @@
# -*- cmake -*-
add_subdirectory(llui_libtest)
IF (LLIMAGE_LIBTEST)
MESSAGE(STATUS "Build llimage_libtest")
add_subdirectory(llimage_libtest)
ELSE (LLIMAGE_LIBTEST)
MESSAGE(STATUS "Skip llimage_libtest")
ENDIF (LLIMAGE_LIBTEST)
add_subdirectory(llimage_libtest)

View File

@ -1,6 +1,7 @@
# -*- cmake -*-
# Integration tests of the llimage library (JPEG2000, PNG, jpeg, etc... images reading and writing)
if (LL_TESTS)
project (llimage_libtest)
@ -8,9 +9,7 @@ include(00-Common)
include(LLCommon)
include(LLImage)
include(LLMath)
include(LLImageJ2COJ)
include(LLKDU)
include(LLFileSystem)
set(llimage_libtest_SOURCE_FILES
llimage_libtest.cpp
@ -24,17 +23,9 @@ set(llimage_libtest_HEADER_FILES
list(APPEND llimage_libtest_SOURCE_FILES ${llimage_libtest_HEADER_FILES})
add_executable(llimage_libtest
WIN32
MACOSX_BUNDLE
${llimage_libtest_SOURCE_FILES}
)
set_target_properties(llimage_libtest
PROPERTIES
WIN32_EXECUTABLE
FALSE
)
# Libraries on which this application depends on
# Sort by high-level to low-level
target_link_libraries(llimage_libtest
@ -42,64 +33,9 @@ target_link_libraries(llimage_libtest
llfilesystem
llmath
llimage
llkdu
llimagej2coj
)
if (DARWIN)
# Path inside the app bundle where we'll need to copy libraries
set(LLIMAGE_LIBTEST_DESTINATION_DIR
${CMAKE_CURRENT_BINARY_DIR}/$<IF:$<BOOL:${LL_GENERATOR_IS_MULTI_CONFIG}>,$<CONFIG>,>/llimage_libtest.app/Contents/Resources
)
# Create the Contents/Resources directory
add_custom_command(
TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS
-E
make_directory
${LLIMAGE_LIBTEST_DESTINATION_DIR}
COMMENT "Creating Resources directory in app bundle."
)
else (DARWIN)
set(LLIMAGE_LIBTEST_DESTINATION_DIR
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/
)
endif (DARWIN)
get_target_property(BUILT_LLCOMMON llcommon LOCATION)
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_LLCOMMON} ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${BUILT_LLCOMMON}
)
if (DARWIN)
# Copy the required libraries to the package app
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libapr-1.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libapr-1.0.dylib
)
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libaprutil-1.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libaprutil-1.0.dylib
)
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib
)
foreach(expat ${EXPAT_COPY})
add_custom_command(TARGET llimage_libtest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat} ${LLIMAGE_LIBTEST_DESTINATION_DIR}
DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat}
)
endforeach(expat)
endif (DARWIN)
if (WINDOWS)
# Check indra/test_apps/llplugintest/CMakeLists.txt for an example of what to copy over for Windows and how
endif (WINDOWS)
# Ensure people working on the viewer don't break this library
# *NOTE: This could be removed, or only built by TeamCity, if the build
# and link times become too long.
add_dependencies(viewer llimage_libtest)
endif(LL_TESTS)

View File

@ -43,6 +43,8 @@
#include "v4coloru.h"
#include "llsdserialize.h"
#include "llcleanup.h"
#include "lltrace.h"
#include "llfasttimer.h"
// system libraries
#include <iostream>
@ -573,10 +575,10 @@ int main(int argc, char** argv)
// Create the logging thread if required
if (LLFastTimer::sMetricLog)
if (LLTrace::BlockTimer::sMetricLog)
{
LLFastTimer::sLogLock = new LLMutex(NULL);
fast_timer_log_thread = new LogThread(LLFastTimer::sLogName);
LLTrace::BlockTimer::setLogLock(new LLMutex());
fast_timer_log_thread = new LogThread(LLTrace::BlockTimer::sLogName);
fast_timer_log_thread->start();
}
@ -618,9 +620,9 @@ int main(int argc, char** argv)
// Output perf data if requested by user
if (analyze_performance)
{
std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
std::string current_name = LLFastTimer::sLogName + ".slp";
std::string report_name = LLFastTimer::sLogName + "_report.csv";
std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
std::string current_name = LLTrace::BlockTimer::sLogName + ".slp";
std::string report_name = LLTrace::BlockTimer::sLogName + "_report.csv";
std::cout << "Analyzing performance, check report in : " << report_name << std::endl;
@ -628,9 +630,9 @@ int main(int argc, char** argv)
}
// Stop the perf gathering system if needed
if (LLFastTimer::sMetricLog)
if (LLTrace::BlockTimer::sMetricLog)
{
LLMetricPerformanceTesterBasic::deleteTester(LLFastTimer::sLogName);
LLMetricPerformanceTesterBasic::deleteTester(LLTrace::BlockTimer::sLogName);
sAllDone = true;
}

View File

@ -34,38 +34,6 @@
#include "llmath.h"
#include "llapr.h"
//#if LL_DARWIN
// MBW -- XXX -- Getting rid of SecondLifeVorbis for now
#if 0
#include "VorbisFramework.h"
#define vorbis_analysis mac_vorbis_analysis
#define vorbis_analysis_headerout mac_vorbis_analysis_headerout
#define vorbis_analysis_init mac_vorbis_analysis_init
#define vorbis_encode_ctl mac_vorbis_encode_ctl
#define vorbis_encode_setup_init mac_vorbis_encode_setup_init
#define vorbis_encode_setup_managed mac_vorbis_encode_setup_managed
#define vorbis_info_init mac_vorbis_info_init
#define vorbis_info_clear mac_vorbis_info_clear
#define vorbis_comment_init mac_vorbis_comment_init
#define vorbis_comment_clear mac_vorbis_comment_clear
#define vorbis_block_init mac_vorbis_block_init
#define vorbis_block_clear mac_vorbis_block_clear
#define vorbis_dsp_clear mac_vorbis_dsp_clear
#define vorbis_analysis_buffer mac_vorbis_analysis_buffer
#define vorbis_analysis_wrote mac_vorbis_analysis_wrote
#define vorbis_analysis_blockout mac_vorbis_analysis_blockout
#define ogg_stream_packetin mac_ogg_stream_packetin
#define ogg_stream_init mac_ogg_stream_init
#define ogg_stream_flush mac_ogg_stream_flush
#define ogg_stream_pageout mac_ogg_stream_pageout
#define ogg_page_eos mac_ogg_page_eos
#define ogg_stream_clear mac_ogg_stream_clear
#endif
S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg)
{
U16 num_channels = 0;

View File

@ -11,7 +11,7 @@ include(LLSharedLibs)
include(Copy3rdPartyLibs)
include(ZLIBNG)
include(Tracy)
include(SSE2NEON)
set(llcommon_SOURCE_FILES
apply.cpp
@ -277,6 +277,7 @@ target_link_libraries(
ll::boost
ll::oslibraries
ll::tracy
ll::sse2neon
)
target_include_directories(llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -12,7 +12,10 @@
#if ! defined(LL_FSYSPATH_H)
#define LL_FSYSPATH_H
#include <boost/iterator/transform_iterator.hpp>
#include <filesystem>
#include <string>
#include <string_view>
// While std::filesystem::path can be directly constructed from std::string on
// both Posix and Windows, that's not what we want on Windows. Per
@ -33,37 +36,43 @@
// char"), the "native narrow encoding" isn't UTF-8, so file paths containing
// non-ASCII characters get mangled.
//
// Once we're building with C++20, we could pass a UTF-8 std::string through a
// vector<char8_t> to engage std::filesystem::path's own UTF-8 conversion. But
// sigh, as of 2024-04-03 we're not yet there.
//
// Anyway, encapsulating the important UTF-8 conversions in our own subclass
// allows us to migrate forward to C++20 conventions without changing
// referencing code.
// Encapsulating the important UTF-8 conversions in our own subclass allows us
// to migrate forward to C++20 conventions without changing referencing code.
class fsyspath: public std::filesystem::path
{
using super = std::filesystem::path;
// In C++20 (__cpp_lib_char8_t), std::filesystem::u8path() is deprecated.
// std::filesystem::path(iter, iter) performs UTF-8 conversions when the
// value_type of the iterators is char8_t. While we could copy into a
// temporary std::u8string and from there into std::filesystem::path, to
// minimize string copying we'll define a transform_iterator that accepts
// a std::string_view::iterator and dereferences to char8_t.
struct u8ify
{
char8_t operator()(char c) const { return char8_t(c); }
};
using u8iter = boost::transform_iterator<u8ify, std::string_view::iterator>;
public:
// default
fsyspath() {}
// construct from UTF-8 encoded std::string
fsyspath(const std::string& path): super(std::filesystem::u8path(path)) {}
// construct from UTF-8 encoded const char*
fsyspath(const char* path): super(std::filesystem::u8path(path)) {}
// construct from UTF-8 encoded string
fsyspath(const std::string& path): fsyspath(std::string_view(path)) {}
fsyspath(const char* path): fsyspath(std::string_view(path)) {}
fsyspath(std::string_view path):
super(u8iter(path.begin(), u8ify()), u8iter(path.end(), u8ify()))
{}
// construct from existing path
fsyspath(const super& path): super(path) {}
fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
fsyspath& operator=(const std::string& p)
fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
fsyspath& operator=(const std::string& p) { return (*this) = std::string_view(p); }
fsyspath& operator=(const char* p) { return (*this) = std::string_view(p); }
fsyspath& operator=(std::string_view p)
{
super::operator=(std::filesystem::u8path(p));
return *this;
}
fsyspath& operator=(const char* p)
{
super::operator=(std::filesystem::u8path(p));
assign(u8iter(p.begin(), u8ify()), u8iter(p.end(), u8ify()));
return *this;
}

View File

@ -28,12 +28,6 @@
#define LL_LINDEN_COMMON_H
#include "llprofiler.h"
#if TRACY_ENABLE && !defined(LL_PROFILER_ENABLE_TRACY_OPENGL) // hooks for memory profiling
void *tracy_aligned_malloc(size_t size, size_t alignment);
void tracy_aligned_free(void *memblock);
#define _aligned_malloc(X, Y) tracy_aligned_malloc((X), (Y))
#define _aligned_free(X) tracy_aligned_free((X))
#endif
// *NOTE: Please keep includes here to a minimum!
//

View File

@ -229,7 +229,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
if(wargv[ii][1] == '-') ++offset;
#if LL_WINDOWS
name.assign(utf16str_to_utf8str(&wargv[ii][offset]));
name.assign(ll_convert_wide_to_string(&wargv[ii][offset]));
#else
name.assign(wstring_to_utf8str(&wargv[ii][offset]));
#endif
@ -253,7 +253,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
++ii;
#if LL_WINDOWS
value.assign(utf16str_to_utf8str((wargv[ii])));
value.assign(ll_convert_wide_to_string((wargv[ii])));
#else
value.assign(wstring_to_utf8str((wargv[ii])));
#endif

View File

@ -33,23 +33,12 @@
#include "lltracethreadrecorder.h"
#include "llcleanup.h"
thread_local bool gProfilerEnabled = false;
#if (TRACY_ENABLE)
#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY && TRACY_ENABLE
// Override new/delete for tracy memory profiling
void* ll_tracy_new(size_t size)
{
void* ptr;
if (gProfilerEnabled)
{
//LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
ptr = (malloc)(size);
}
else
{
ptr = (malloc)(size);
}
void* ptr = (malloc)(size);
if (!ptr)
{
throw std::bad_alloc();
@ -58,6 +47,29 @@ void* ll_tracy_new(size_t size)
return ptr;
}
void* ll_tracy_aligned_new(size_t size, size_t alignment)
{
void* ptr = ll_aligned_malloc_fallback(size, alignment);
if (!ptr)
{
throw std::bad_alloc();
}
LL_PROFILE_ALLOC(ptr, size);
return ptr;
}
void ll_tracy_delete(void* ptr)
{
LL_PROFILE_FREE(ptr);
(free)(ptr);
}
void ll_tracy_aligned_delete(void* ptr)
{
LL_PROFILE_FREE(ptr);
ll_aligned_free_fallback(ptr);
}
void* operator new(size_t size)
{
return ll_tracy_new(size);
@ -68,18 +80,14 @@ void* operator new[](std::size_t count)
return ll_tracy_new(count);
}
void ll_tracy_delete(void* ptr)
void* operator new(size_t size, std::align_val_t align)
{
LL_PROFILE_FREE(ptr);
if (gProfilerEnabled)
{
//LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
(free)(ptr);
}
else
{
(free)(ptr);
}
return ll_tracy_aligned_new(size, (size_t)align);
}
void* operator new[](std::size_t count, std::align_val_t align)
{
return ll_tracy_aligned_new(count, (size_t)align);
}
void operator delete(void *ptr) noexcept
@ -92,27 +100,17 @@ void operator delete[](void* ptr) noexcept
ll_tracy_delete(ptr);
}
// C-style malloc/free can't be so easily overridden, so we define tracy versions and use
// a pre-processor #define in linden_common.h to redirect to them. The parens around the native
// functions below prevents recursive substitution by the preprocessor.
//
// Unaligned mallocs are rare in LL code but hooking them causes problems in 3p lib code (looking at
// you, Havok), so we'll only capture the aligned version.
void *tracy_aligned_malloc(size_t size, size_t alignment)
void operator delete(void *ptr, std::align_val_t align) noexcept
{
auto ptr = ll_aligned_malloc_fallback(size, alignment);
if (ptr) LL_PROFILE_ALLOC(ptr, size);
return ptr;
ll_tracy_aligned_delete(ptr);
}
void tracy_aligned_free(void *memblock)
void operator delete[](void* ptr, std::align_val_t align) noexcept
{
LL_PROFILE_FREE(memblock);
ll_aligned_free_fallback(memblock);
ll_tracy_aligned_delete(ptr);
}
#endif
#endif // TRACY_ENABLE && !LL_PROFILER_ENABLE_TRACY_OPENGL
//static
bool LLCommon::sAprInitialized = false;

View File

@ -79,7 +79,7 @@ namespace {
//
if (s.size())
{
OutputDebugString(utf8str_to_utf16str(s).c_str());
OutputDebugString(ll_convert<std::wstring>(s).c_str());
OutputDebugString(TEXT("\n"));
}
}

View File

@ -64,7 +64,7 @@ bool BlockTimer::sLog = false;
std::string BlockTimer::sLogName = "";
bool BlockTimer::sMetricLog = false;
#if LL_LINUX
#if LL_LINUX || (LL_DARWIN && LL_ARM64)
U64 BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution
#else
U64 BlockTimer::sClockResolution = 1000000; // Microsecond resolution

View File

@ -30,9 +30,14 @@
#include "llinstancetracker.h"
#include "lltrace.h"
#include "lltreeiterators.h"
#include "llprocessor.h"
#if LL_X86 || LL_X86_64
#if LL_WINDOWS
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
#endif
#define LL_FAST_TIMER_ON 1
@ -68,35 +73,10 @@ public:
//
// Windows implementation of CPU clock
//
//
// NOTE: put back in when we aren't using platform sdk anymore
//
// because MS has different signatures for these functions in winnt.h
// need to rename them to avoid conflicts
//#define _interlockedbittestandset _renamed_interlockedbittestandset
//#define _interlockedbittestandreset _renamed_interlockedbittestandreset
//#include <intrin.h>
//#undef _interlockedbittestandset
//#undef _interlockedbittestandreset
//inline U32 getCPUClockCount32()
//{
// U64 time_stamp = __rdtsc();
// return (U32)(time_stamp >> 8);
//}
//
//// return full timer value, *not* shifted by 8 bits
//inline U64 getCPUClockCount64()
//{
// return __rdtsc();
//}
#if LL_FASTTIMER_USE_RDTSC
// shift off lower 8 bits for lower resolution but longer term timing
// on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing
#if LL_FASTTIMER_USE_RDTSC
static U32 getCPUClockCount32()
{
unsigned __int64 val = __rdtsc();
@ -159,23 +139,37 @@ public:
#endif // (LL_LINUX) && !(defined(__i386__) || defined(__amd64__))
#if (LL_LINUX || LL_DARWIN) && (defined(__i386__) || defined(__amd64__))
#if LL_DARWIN && LL_ARM64
//
// Mac+Linux FAST x86 implementation of CPU clock
// Mac implementation of CPU clock - non-x86.
//
static U64 getCPUClockCount64()
{
return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
}
static U32 getCPUClockCount32()
{
U32 low(0),high(0);
__asm__ volatile (".byte 0x0f, 0x31": "=a"(low), "=d"(high) );
return (low>>8) | (high<<24);
return (U32)(getCPUClockCount64() >> 8);
}
#endif // LL_DARWIN && LL_ARM64
#if (LL_LINUX || LL_DARWIN) && (LL_X86 || LL_X86_64)
//
// Mac+Linux FAST x86 implementation of CPU clock
//
#if LL_FASTTIMER_USE_RDTSC
static U32 getCPUClockCount32()
{
U64 time_stamp = __rdtsc() >> 8U;
return static_cast<U32>(time_stamp);
}
static U64 getCPUClockCount64()
{
U32 low(0),high(0);
__asm__ volatile (".byte 0x0f, 0x31": "=a"(low), "=d"(high) );
return (U64)low | ( ((U64)high) << 32);
return static_cast<U64>(__rdtsc());
}
#endif
#endif
static BlockTimerStatHandle& getRootTimeBlock();

View File

@ -178,8 +178,7 @@ int LLFile::mkdir(const std::string& dirname, int perms)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
std::wstring utf16dirname = ll_convert<std::wstring>(dirname);
int rc = _wmkdir(utf16dirname.c_str());
#else
int rc = ::mkdir(dirname.c_str(), (mode_t)perms);
@ -201,8 +200,7 @@ int LLFile::rmdir(const std::string& dirname)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
std::wstring utf16dirname = ll_convert<std::wstring>(dirname);
int rc = _wrmdir(utf16dirname.c_str());
#else
int rc = ::rmdir(dirname.c_str());
@ -214,10 +212,8 @@ int LLFile::rmdir(const std::string& dirname)
LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfinder: ignore */
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
std::wstring utf16mode = ll_convert<std::wstring>(std::string(mode));
return _wfopen(utf16filename.c_str(),utf16mode.c_str());
#else
return ::fopen(filename.c_str(),mode); /* Flawfinder: ignore */
@ -227,10 +223,8 @@ LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawf
LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
std::wstring utf16mode = ll_convert<std::wstring>(std::string(mode));
return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);
#else
llassert(0);//No corresponding function on non-windows
@ -270,8 +264,7 @@ std::string LLFile::getContents(const std::string& filename)
int LLFile::remove(const std::string& filename, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
int rc = _wremove(utf16filename.c_str());
#else
int rc = ::remove(filename.c_str());
@ -282,10 +275,8 @@ int LLFile::remove(const std::string& filename, int supress_error)
int LLFile::rename(const std::string& filename, const std::string& newname, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8newname = newname;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
llutf16string utf16newname = utf8str_to_utf16str(utf8newname);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
std::wstring utf16newname = ll_convert<std::wstring>(newname);
int rc = _wrename(utf16filename.c_str(),utf16newname.c_str());
#else
int rc = ::rename(filename.c_str(),newname.c_str());
@ -327,8 +318,7 @@ bool LLFile::copy(const std::string& from, const std::string& to)
int LLFile::stat(const std::string& filename, llstat* filestatus)
{
#if LL_WINDOWS
std::string utf8filename = filename;
llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
std::wstring utf16filename = ll_convert<std::wstring>(filename);
int rc = _wstat(utf16filename.c_str(),filestatus);
#else
int rc = ::stat(filename.c_str(),filestatus);
@ -453,14 +443,14 @@ llifstream::llifstream() {}
// explicit
llifstream::llifstream(const std::string& _Filename, ios_base::openmode _Mode):
std::ifstream(utf8str_to_utf16str( _Filename ).c_str(),
std::ifstream(ll_convert<std::wstring>( _Filename ).c_str(),
_Mode | ios_base::in)
{
}
void llifstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
std::ifstream::open(utf8str_to_utf16str(_Filename).c_str(),
std::ifstream::open(ll_convert<std::wstring>(_Filename).c_str(),
_Mode | ios_base::in);
}
@ -472,14 +462,14 @@ llofstream::llofstream() {}
// explicit
llofstream::llofstream(const std::string& _Filename, ios_base::openmode _Mode):
std::ofstream(utf8str_to_utf16str( _Filename ).c_str(),
std::ofstream(ll_convert<std::wstring>( _Filename ).c_str(),
_Mode | ios_base::out)
{
}
void llofstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
std::ofstream::open(utf8str_to_utf16str( _Filename ).c_str(),
std::ofstream::open(ll_convert<std::wstring>( _Filename ).c_str(),
_Mode | ios_base::out);
}

View File

@ -255,6 +255,11 @@ void LLMD5::raw_digest(unsigned char* s) const
memcpy(s, digest, 16); /* Flawfinder: ignore */
}
#if LL_DARWIN
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
void LLMD5::hex_digest(char* s) const
{
if (!finalized)
@ -273,6 +278,10 @@ void LLMD5::hex_digest(char* s) const
s[32] = '\0';
}
#if LL_DARWIN
#pragma clang diagnostic push
#endif
std::ostream& operator<<(std::ostream& stream, const LLMD5& context)
{
char s[33]; /* Flawfinder: ignore */

View File

@ -71,7 +71,11 @@ LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
#define ll_assert_aligned(ptr,alignment)
#endif
#if LL_ARM64
#include "sse2neon.h"
#else
#include <xmmintrin.h>
#endif
template <typename T> T* LL_NEXT_ALIGNED_ADDRESS(T* address)
{
@ -231,8 +235,6 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
#if defined(LL_WINDOWS)
void* ret = _aligned_malloc(size, 32);
#elif defined(LL_DARWIN)
void* ret = ll_aligned_malloc_fallback( size, 32 );
#else
void *ret;
if (0 != posix_memalign(&ret, 32, size))
@ -248,8 +250,31 @@ inline void ll_aligned_free_32(void *p)
LL_PROFILE_FREE(p);
#if defined(LL_WINDOWS)
_aligned_free(p);
#elif defined(LL_DARWIN)
ll_aligned_free_fallback( p );
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
}
inline void* ll_aligned_malloc_64(size_t size) // returned hunk MUST be freed with ll_aligned_free_32().
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
#if defined(LL_WINDOWS)
void* ret = _aligned_malloc(size, 64);
#else
void *ret;
if (0 != posix_memalign(&ret, 64, size))
return nullptr;
#endif
LL_PROFILE_ALLOC(ret, size);
return ret;
}
inline void ll_aligned_free_64(void *p)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
LL_PROFILE_FREE(p);
#if defined(LL_WINDOWS)
_aligned_free(p);
#else
free(p); // posix_memalign() is compatible with heap deallocator
#endif
@ -261,19 +286,23 @@ LL_FORCE_INLINE void* ll_aligned_malloc(size_t size)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
void* ret;
if (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0)
if constexpr (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0)
{
ret = malloc(size);
LL_PROFILE_ALLOC(ret, size);
}
else if (ALIGNMENT == 16)
else if constexpr (ALIGNMENT == 16)
{
ret = ll_aligned_malloc_16(size);
}
else if (ALIGNMENT == 32)
else if constexpr (ALIGNMENT == 32)
{
ret = ll_aligned_malloc_32(size);
}
else if constexpr (ALIGNMENT == 64)
{
ret = ll_aligned_malloc_64(size);
}
else
{
ret = ll_aligned_malloc_fallback(size, ALIGNMENT);
@ -285,16 +314,20 @@ template<size_t ALIGNMENT>
LL_FORCE_INLINE void ll_aligned_free(void* ptr)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
if constexpr (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)
{
LL_PROFILE_FREE(ptr);
free(ptr);
}
else if (ALIGNMENT == 16)
else if constexpr (ALIGNMENT == 16)
{
ll_aligned_free_16(ptr);
}
else if (ALIGNMENT == 32)
else if constexpr (ALIGNMENT == 32)
{
return ll_aligned_free_32(ptr);
}
else if constexpr (ALIGNMENT == 64)
{
return ll_aligned_free_32(ptr);
}
@ -310,6 +343,9 @@ LL_FORCE_INLINE void ll_aligned_free(void* ptr)
inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;
#if defined(LL_ARM64)
memcpy(dst, src, bytes);
#else
assert(src != NULL);
assert(dst != NULL);
assert(bytes > 0);
@ -375,6 +411,7 @@ inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __
dst += 16;
src += 16;
}
#endif
}
#ifndef __DEBUG_PRIVATE_MEM__

View File

@ -76,6 +76,23 @@
#endif
#endif
// Set up CPU architecture defines
#if LL_MSVC && defined(_M_ARM64)
# define LL_ARM64 1
#elif LL_GNUC && (defined(__arm64__) || defined(__aarch64__))
# define LL_ARM64 1
#elif LL_MSVC && _M_X64
# define LL_X86_64 1
# define LL_X86 1
#elif LL_MSVC && _M_IX86
# define LL_X86 1
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
# define LL_X86_64 1
# define LL_X86 1
#elif LL_GNUC && ( defined(__i386__) )
# define LL_X86 1
#endif
// Deal with minor differences on Unixy OSes.
#if LL_DARWIN || LL_LINUX
// Different name, same functionality.
@ -118,11 +135,8 @@
#if LL_WINDOWS
#define LL_DLLEXPORT __declspec(dllexport)
#define LL_DLLIMPORT __declspec(dllimport)
#elif LL_LINUX
#define LL_DLLEXPORT __attribute__ ((visibility("default")))
#define LL_DLLIMPORT
#else
#define LL_DLLEXPORT
#define LL_DLLEXPORT __attribute__ ((visibility("default")))
#define LL_DLLIMPORT
#endif // LL_WINDOWS
@ -167,7 +181,7 @@
#define LL_TO_STRING_HELPER(x) #x
#define LL_TO_STRING(x) LL_TO_STRING_HELPER(x)
#define LL_TO_WSTRING_HELPER(x) L#x
#define LL_TO_WSTRING_HELPER(x) L## #x
#define LL_TO_WSTRING(x) LL_TO_WSTRING_HELPER(x)
#define LL_FILE_LINENO_MSG(msg) __FILE__ "(" LL_TO_STRING(__LINE__) ") : " msg
#define LL_GLUE_IMPL(x, y) x##y
@ -187,4 +201,16 @@
#define LL_PRETTY_FUNCTION __PRETTY_FUNCTION__
#endif
#if LL_ARM64
#define GLM_FORCE_NEON 1
#else
#define GLM_FORCE_SSE2 1
#endif
#if LL_ARM64
#define KDU_NEON_INTRINSICS 1
#else
#define KDU_X86_INTRINSICS 1
#endif
#endif // not LL_LINDEN_PREPROCESSOR_H

View File

@ -628,6 +628,8 @@ private:
#elif LL_DARWIN
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
#include <mach/machine.h>
#include <sys/sysctl.h>
@ -638,25 +640,21 @@ public:
{
getCPUIDInfo();
uint64_t frequency = getSysctlInt64("hw.cpufrequency");
if (!frequency)
if (frequency == 0) // fallback to clockrate and tbfrequency
{
auto tbfrequency = getSysctlInt64("hw.tbfrequency");
struct clockinfo clockrate;
auto clockrate_len = sizeof(clockrate);
if (!sysctlbyname("kern.clockrate", &clockrate, &clockrate_len, NULL, 0))
frequency = tbfrequency * clockrate.hz;
frequency = getSysctlClockrate() * getSysctlInt64("hw.tbfrequency");
}
setInfo(eFrequency, (F64)frequency / (F64)1000000);
}
virtual ~LLProcessorInfoDarwinImpl() {}
virtual ~LLProcessorInfoDarwinImpl() = default;
private:
int getSysctlInt(const char* name)
{
int result = 0;
size_t len = sizeof(int);
int error = sysctlbyname(name, (void*)&result, &len, NULL, 0);
int error = sysctlbyname(name, (void*)&result, &len, nullptr, 0);
return error == -1 ? 0 : result;
}
@ -664,7 +662,7 @@ private:
{
uint64_t value = 0;
size_t size = sizeof(value);
int result = sysctlbyname(name, (void*)&value, &size, NULL, 0);
int result = sysctlbyname(name, (void*)&value, &size, nullptr, 0);
if ( result == 0 )
{
if ( size == sizeof( uint64_t ) )
@ -684,6 +682,14 @@ private:
return result == -1 ? 0 : value;
}
uint64_t getSysctlClockrate()
{
struct clockinfo clockrate{};
size_t size = sizeof(clockrate);
int error = sysctlbyname("kern.clockrate", &clockrate, &size, nullptr, 0);
return error == -1 ? 0 : clockrate.hz;
}
void getCPUIDInfo()
{
size_t len = 0;

View File

@ -28,20 +28,7 @@
#ifndef LLPROCESSOR_H
#define LLPROCESSOR_H
#include "llunits.h"
#if LL_MSVC && _M_X64
# define LL_X86_64 1
# define LL_X86 1
#elif LL_MSVC && _M_IX86
# define LL_X86 1
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
# define LL_X86_64 1
# define LL_X86 1
#elif LL_GNUC && ( defined(__i386__) )
# define LL_X86 1
#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
# define LL_PPC 1
#endif
#include "llpreprocessor.h"
class LLProcessorInfoImpl;

View File

@ -74,23 +74,18 @@
#define LL_PROFILER_CONFIGURATION LL_PROFILER_CONFIG_FAST_TIMER
#endif
extern thread_local bool gProfilerEnabled;
#if defined(LL_PROFILER_CONFIGURATION) && (LL_PROFILER_CONFIGURATION > LL_PROFILER_CONFIG_NONE)
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY || LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER
#include "tracy/Tracy.hpp"
// Enable OpenGL profiling
#define LL_PROFILER_ENABLE_TRACY_OPENGL 0
// Enable RenderDoc labeling
#define LL_PROFILER_ENABLE_RENDER_DOC 0
//#define LL_PROFILER_ENABLE_RENDER_DOC 0
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY
#define LL_PROFILER_FRAME_END FrameMark
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name ); gProfilerEnabled = true;
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name );
#define LL_RECORD_BLOCK_TIME(name) ZoneScoped // Want descriptive names; was: ZoneNamedN( ___tracy_scoped_zone, #name, true );
#define LL_PROFILE_ZONE_NAMED(name) ZoneNamedN( ___tracy_scoped_zone, name, true );
#define LL_PROFILE_ZONE_NAMED_COLOR(name,color) ZoneNamedNC( ___tracy_scopped_zone, name, color, true ) // RGB
@ -133,7 +128,7 @@ extern thread_local bool gProfilerEnabled;
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER
#define LL_PROFILER_FRAME_END FrameMark
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name ); gProfilerEnabled = true;
#define LL_PROFILER_SET_THREAD_NAME( name ) tracy::SetThreadName( name );
#define LL_RECORD_BLOCK_TIME(name) ZoneNamedN(___tracy_scoped_zone, #name, true); const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(name)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);
#define LL_PROFILE_ZONE_NAMED(name) ZoneNamedN( ___tracy_scoped_zone, #name, true );
#define LL_PROFILE_ZONE_NAMED_COLOR(name,color) ZoneNamedNC( ___tracy_scopped_zone, name, color, true ) // RGB
@ -158,23 +153,20 @@ extern thread_local bool gProfilerEnabled;
#endif // LL_PROFILER
#if LL_PROFILER_ENABLE_TRACY_OPENGL
#define LL_PROFILE_GPU_ZONE(name) TracyGpuZone(name)
#define LL_PROFILE_GPU_ZONEC(name,color) TracyGpuZoneC(name,color)
#define LL_PROFILE_GPU_ZONE(name) TracyGpuZone(name)
#define LL_PROFILE_GPU_ZONEC(name,color) TracyGpuZoneC(name,color)
#define LL_PROFILER_GPU_COLLECT TracyGpuCollect
#define LL_PROFILER_GPU_CONTEXT TracyGpuContext
// disable memory tracking (incompatible with GPU tracing
#define LL_PROFILE_ALLOC(ptr, size) (void)(ptr); (void)(size);
#define LL_PROFILE_FREE(ptr) (void)(ptr);
#define LL_PROFILER_GPU_CONTEXT_NAMED TracyGpuContextName
#else
#define LL_PROFILE_GPU_ZONE(name) (void)name;
#define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color;
#define LL_PROFILE_GPU_ZONE(name) (void)name;
#define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color;
#define LL_PROFILER_GPU_COLLECT
#define LL_PROFILER_GPU_CONTEXT
#define LL_PROFILER_GPU_CONTEXT_NAMED(name) (void)name;
#endif // LL_PROFILER_ENABLE_TRACY_OPENGL
#define LL_LABEL_OBJECT_GL(type, name, length, label)
#if !LL_DARWIN && LL_PROFILER_CONFIGURATION > 1
#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY
#define LL_PROFILE_ALLOC(ptr, size) TracyAlloc(ptr, size)
#define LL_PROFILE_FREE(ptr) TracyFree(ptr)
#else
@ -182,8 +174,6 @@ extern thread_local bool gProfilerEnabled;
#define LL_PROFILE_FREE(ptr) (void)(ptr);
#endif
#endif
#if LL_PROFILER_ENABLE_RENDER_DOC
#define LL_LABEL_OBJECT_GL(type, name, length, label) glObjectLabel(type, name, length, label)
#else

View File

@ -192,6 +192,9 @@ LLOSInfo::LLOSInfo() :
GetSystemInfo(&si); //if it fails get regular system info
//(Warning: If GetSystemInfo it may result in incorrect information in a WOW64 machine, if the kernel fails to load)
#pragma warning(push)
#pragma warning(disable : 4996) // ignore 'deprecated.' GetVersionEx is deprecated
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
@ -210,6 +213,8 @@ LLOSInfo::LLOSInfo() :
}
}
#pragma warning(pop)
S32 ubr = 0; // Windows 10 Update Build Revision, can be retrieved from a registry
if (mMajorVer == 10)
{
@ -1323,7 +1328,7 @@ bool gunzip_file(const std::string& srcfile, const std::string& dstfile)
S32 bytes = 0;
tmpfile = dstfile + ".t";
#ifdef LL_WINDOWS
llutf16string utf16filename = utf8str_to_utf16str(srcfile);
std::wstring utf16filename = ll_convert<std::wstring>(srcfile);
src = gzopen_w(utf16filename.c_str(), "rb");
#else
src = gzopen(srcfile.c_str(), "rb");
@ -1367,7 +1372,7 @@ bool gzip_file(const std::string& srcfile, const std::string& dstfile)
tmpfile = dstfile + ".t";
#ifdef LL_WINDOWS
llutf16string utf16filename = utf8str_to_utf16str(tmpfile);
std::wstring utf16filename = ll_convert<std::wstring>(tmpfile);
dst = gzopen_w(utf16filename.c_str(), "wb");
#else
dst = gzopen(tmpfile.c_str(), "wb");

View File

@ -452,7 +452,9 @@ ElementT LLThreadSafeQueue<ElementT, QueueT>::pop(void)
// so we can finish draining the queue.
pop_result popped = pop_(lock1, value);
if (popped == POPPED)
return std::move(value);
// don't use std::move when returning local value because
// it prevents the compiler from optimizing with copy elision
return value;
// Once the queue is DONE, there will never be any more coming.
if (popped == DONE)

View File

@ -110,6 +110,17 @@ namespace tut
void stringize_object::test<3>()
{
//Tests rely on validity of wstring_to_utf8str()
#if LL_WINDOWS // Windows wstring is a 2byte UTF16 type
ensure_equals(ll_convert<std::string>(wstringize(c)), ll_convert<std::string>(std::wstring(L"c")));
ensure_equals(ll_convert<std::string>(wstringize(s)), ll_convert<std::string>(std::wstring(L"17")));
ensure_equals(ll_convert<std::string>(wstringize(i)), ll_convert<std::string>(std::wstring(L"34")));
ensure_equals(ll_convert<std::string>(wstringize(l)), ll_convert<std::string>(std::wstring(L"68")));
ensure_equals(ll_convert<std::string>(wstringize(f)), ll_convert<std::string>(std::wstring(L"3.14159")));
ensure_equals(ll_convert<std::string>(wstringize(d)), ll_convert<std::string>(std::wstring(L"3.14159")));
ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(std::wstring(L"abc def")));
ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(wstringize(abc.c_str())));
ensure_equals(ll_convert<std::string>(wstringize(def)), ll_convert<std::string>(std::wstring(L"def ghi")));
#else
ensure_equals(wstring_to_utf8str(wstringize(c)), wstring_to_utf8str(L"c"));
ensure_equals(wstring_to_utf8str(wstringize(s)), wstring_to_utf8str(L"17"));
ensure_equals(wstring_to_utf8str(wstringize(i)), wstring_to_utf8str(L"34"));
@ -119,6 +130,7 @@ namespace tut
ensure_equals(wstring_to_utf8str(wstringize(abc)), wstring_to_utf8str(L"abc def"));
ensure_equals(wstring_to_utf8str(wstringize(abc)), wstring_to_utf8str(wstringize(abc.c_str())));
ensure_equals(wstring_to_utf8str(wstringize(def)), wstring_to_utf8str(L"def ghi"));
#endif
// ensure_equals(wstring_to_utf8str(wstringize(llsd)), wstring_to_utf8str(L"{'abc':'abc def','d':r3.14159,'i':i34}"));
}
} // namespace tut

View File

@ -52,8 +52,6 @@
void init_curl();
void term_curl();
void ssl_thread_id_callback(CRYPTO_THREADID*);
void ssl_locking_callback(int mode, int type, const char * file, int line);
void usage(std::ostream & out);
// Default command line settings
@ -606,63 +604,15 @@ void WorkingSet::loadAssetUuids(FILE * in)
}
int ssl_mutex_count(0);
LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
void init_curl()
{
curl_global_init(CURL_GLOBAL_ALL);
ssl_mutex_count = CRYPTO_num_locks();
if (ssl_mutex_count > 0)
{
ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
for (int i(0); i < ssl_mutex_count; ++i)
{
ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
}
CRYPTO_set_locking_callback(ssl_locking_callback);
CRYPTO_THREADID_set_callback(ssl_thread_id_callback);
}
}
void term_curl()
{
CRYPTO_set_locking_callback(NULL);
for (int i(0); i < ssl_mutex_count; ++i)
{
delete ssl_mutex_list[i];
}
delete [] ssl_mutex_list;
}
void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid)
{
#if defined(WIN32)
CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread());
#else
CRYPTO_THREADID_set_pointer(pthreadid, pthread_self());
#endif
}
void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
{
if (type >= 0 && type < ssl_mutex_count)
{
if (mode & CRYPTO_LOCK)
{
ssl_mutex_list[type]->lock();
}
else
{
ssl_mutex_list[type]->unlock();
}
}
curl_global_cleanup();
}

View File

@ -41,11 +41,7 @@
#include "test_httpstatus.hpp"
#include "test_refcounted.hpp"
#include "test_httpoperation.hpp"
// As of 2019-06-28, test_httprequest.hpp consistently crashes on Mac Release
// builds for reasons not yet diagnosed.
#if ! (LL_DARWIN && LL_RELEASE)
#include "test_httprequest.hpp"
#endif
#include "test_httpheaders.hpp"
#include "test_httprequestqueue.hpp"
#include "_httpservice.h"
@ -53,9 +49,6 @@
#include "llproxy.h"
#include "llcleanup.h"
void ssl_thread_id_callback(CRYPTO_THREADID*);
void ssl_locking_callback(int mode, int type, const char * file, int line);
#if 0 // lltut provides main and runner
namespace tut
@ -80,27 +73,10 @@ int main()
#endif // 0
int ssl_mutex_count(0);
LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
void init_curl()
{
curl_global_init(CURL_GLOBAL_ALL);
ssl_mutex_count = CRYPTO_num_locks();
if (ssl_mutex_count > 0)
{
ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
for (int i(0); i < ssl_mutex_count; ++i)
{
ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
}
CRYPTO_set_locking_callback(ssl_locking_callback);
CRYPTO_THREADID_set_callback(ssl_thread_id_callback);
}
LLProxy::getInstance();
}
@ -108,39 +84,6 @@ void init_curl()
void term_curl()
{
SUBSYSTEM_CLEANUP(LLProxy);
CRYPTO_set_locking_callback(NULL);
for (int i(0); i < ssl_mutex_count; ++i)
{
delete ssl_mutex_list[i];
}
delete [] ssl_mutex_list;
}
void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid)
{
#if defined(WIN32)
CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread());
#else
CRYPTO_THREADID_set_pointer(pthreadid, pthread_self());
#endif
}
void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
{
if (type >= 0 && type < ssl_mutex_count)
{
if (mode & CRYPTO_LOCK)
{
ssl_mutex_list[type]->lock();
}
else
{
ssl_mutex_list[type]->unlock();
}
}
}

View File

@ -454,6 +454,10 @@ void HttpRequestTestObjectType::test<4>()
template <> template <>
void HttpRequestTestObjectType::test<5>()
{
#ifndef LL_WINDOWS
skip("Skip due to issues with testing pthread cancellation");
#endif
ScopedCurlInit ready;
set_test_name("HttpRequest Spin (soft) + NoOp + hard termination");
@ -517,6 +521,9 @@ void HttpRequestTestObjectType::test<5>()
template <> template <>
void HttpRequestTestObjectType::test<6>()
{
#ifndef LL_WINDOWS
skip("Skip due to issues with testing pthread cancellation");
#endif
ScopedCurlInit ready;
set_test_name("HttpRequest Spin + NoOp + hard termination");
@ -2779,7 +2786,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test_count; ++i)
{
char buffer[128];
sprintf(buffer, "/bug2295/%d/", i);
snprintf(buffer, sizeof(buffer), "/bug2295/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
@ -2810,7 +2817,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test2_count; ++i)
{
char buffer[128];
sprintf(buffer, "/bug2295/00000012/%d/", i);
snprintf(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
@ -2841,7 +2848,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test3_count; ++i)
{
char buffer[128];
sprintf(buffer, "/bug2295/inv_cont_range/%d/", i);
snprintf(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,

View File

@ -28,8 +28,6 @@
#include "_refcounted.h"
// disable all of this because it's hanging win64 builds?
#if ! (LL_WINDOWS && ADDRESS_SIZE == 64)
using namespace LLCoreInt;
namespace tut
@ -122,5 +120,4 @@ namespace tut
ensure(rc->getRefCount() == RefCounted::NOT_REF_COUNTED);
}
}
#endif // disabling on Win64
#endif // TEST_LLCOREINT_REF_COUNTED_H_

View File

@ -189,7 +189,7 @@ LLSD LLCrashLock::getProcessList()
bool LLCrashLock::fileExists(std::string filename)
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path file_path(utf8str_to_utf16str(filename));
boost::filesystem::path file_path(ll_convert<std::wstring>(filename));
#else
boost::filesystem::path file_path(filename);
#endif
@ -199,7 +199,7 @@ bool LLCrashLock::fileExists(std::string filename)
void LLCrashLock::cleanupProcess(std::string proc_dir)
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path dir_path(utf8str_to_utf16str(proc_dir));
boost::filesystem::path dir_path(ll_convert<std::wstring>(proc_dir));
#else
boost::filesystem::path dir_path(proc_dir);
#endif

View File

@ -103,7 +103,7 @@ std::vector<std::string> LLDir::getFilesInDir(const std::string &dirname)
//Returns a vector of fullpath filenames.
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path p(utf8str_to_utf16str(dirname));
boost::filesystem::path p(ll_convert<std::wstring>(dirname));
#else
boost::filesystem::path p(dirname);
#endif
@ -197,7 +197,7 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name)
try
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
boost::filesystem::path dir_path(utf8str_to_utf16str(dir_name));
boost::filesystem::path dir_path(ll_convert<std::wstring>(dir_name));
#else
boost::filesystem::path dir_path(dir_name);
#endif

View File

@ -149,7 +149,7 @@ LLDir_Mac::LLDir_Mac()
mWorkingDir = getCurPath();
mLLPluginDir = mAppRODataDir + mDirDelimiter + "llplugin";
mLLPluginDir = mAppRODataDir + mDirDelimiter + "SLPlugin.app" + mDirDelimiter + "Contents" + mDirDelimiter + "Frameworks";
}
}

View File

@ -172,7 +172,7 @@ LLDir_Win32::LLDir_Win32()
{
w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash
}
mTempDir = utf16str_to_utf8str(llutf16string(w_str));
mTempDir = ll_convert<std::string>(std::wstring(w_str));
if (mOSUserDir.empty())
{
@ -225,14 +225,14 @@ LLDir_Win32::LLDir_Win32()
// Set working directory, for LLDir::getWorkingDir()
GetCurrentDirectory(MAX_PATH, w_str);
mWorkingDir = utf16str_to_utf8str(llutf16string(w_str));
mWorkingDir = ll_convert<std::string>(std::wstring(w_str));
// Set the executable directory
S32 size = GetModuleFileName(NULL, w_str, MAX_PATH);
if (size)
{
w_str[size] = '\0';
mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str));
mExecutablePathAndName = ll_convert<std::string>(std::wstring(w_str));
auto path_end = mExecutablePathAndName.find_last_of('\\');
if (path_end != std::string::npos)
{
@ -347,8 +347,8 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string &
WIN32_FIND_DATA FileData;
llutf16string pathname = utf8str_to_utf16str(dirname);
pathname += utf8str_to_utf16str(mask);
std::wstring pathname = ll_convert<std::wstring>(dirname);
pathname += ll_convert<std::wstring>(mask);
if ((count_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)
{
@ -370,7 +370,7 @@ std::string LLDir_Win32::getCurPath()
WCHAR w_str[MAX_PATH];
GetCurrentDirectory(MAX_PATH, w_str);
return utf16str_to_utf8str(llutf16string(w_str));
return ll_convert<std::string>(std::wstring(w_str));
}

View File

@ -51,7 +51,7 @@ public:
private:
void* mDirSearch_h{ nullptr };
llutf16string mCurrentDir;
std::wstring mCurrentDir;
};
#endif // LL_LLDIR_WIN32_H

View File

@ -31,6 +31,9 @@
#include "llerror.h"
#if LL_WINDOWS
#include "llwin32headers.h"
class LLDirectoryGuard
{
public:
@ -46,8 +49,8 @@ public:
(wcsncmp(mOrigDir,mFinalDir,mOrigDirLen)!=0))
{
// Dir has changed
std::string mOrigDirUtf8 = utf16str_to_utf8str(llutf16string(mOrigDir));
std::string mFinalDirUtf8 = utf16str_to_utf8str(llutf16string(mFinalDir));
std::string mOrigDirUtf8 = ll_convert<std::string>(std::wstring(mOrigDir));
std::string mFinalDirUtf8 = ll_convert<std::string>(std::wstring(mFinalDir));
LL_INFOS() << "Resetting working dir from " << mFinalDirUtf8 << " to " << mOrigDirUtf8 << LL_ENDL;
SetCurrentDirectory(mOrigDir);
}

View File

@ -52,7 +52,7 @@ LLDirIterator::Impl::Impl(const std::string &dirname, const std::string &mask)
: mIsValid(false)
{
#ifdef LL_WINDOWS // or BOOST_WINDOWS_API
fs::path dir_path(utf8str_to_utf16str(dirname));
fs::path dir_path(ll_convert<std::wstring>(dirname));
#else
fs::path dir_path(dirname);
#endif

View File

@ -103,7 +103,7 @@ void LLDiskCache::purge()
std::vector<file_info_t> file_info;
#if LL_WINDOWS
std::wstring cache_path(utf8str_to_utf16str(sCacheDir));
std::wstring cache_path(ll_convert<std::wstring>(sCacheDir));
#else
std::string cache_path(sCacheDir);
#endif
@ -226,7 +226,7 @@ void LLDiskCache::clearCache()
*/
boost::system::error_code ec;
#if LL_WINDOWS
std::wstring cache_path(utf8str_to_utf16str(sCacheDir));
std::wstring cache_path(ll_convert<std::wstring>(sCacheDir));
#else
std::string cache_path(sCacheDir);
#endif
@ -259,7 +259,7 @@ void LLDiskCache::removeOldVFSFiles()
boost::system::error_code ec;
#if LL_WINDOWS
std::wstring cache_path(utf8str_to_utf16str(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")));
std::wstring cache_path(ll_convert<std::wstring>(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")));
#else
std::string cache_path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""));
#endif
@ -300,7 +300,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string& dir)
*/
boost::system::error_code ec;
#if LL_WINDOWS
std::wstring dir_path(utf8str_to_utf16str(dir));
std::wstring dir_path(ll_convert<std::wstring>(dir));
#else
std::string dir_path(dir);
#endif

View File

@ -316,7 +316,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path)
boost::system::error_code ec;
#if LL_WINDOWS
// file last write time
const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec);
const std::time_t last_write_time = boost::filesystem::last_write_time(ll_convert<std::wstring>(file_path), ec);
if (ec.failed())
{
LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL;
@ -330,7 +330,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path)
// before the last one
if (delta_time > time_threshold)
{
boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec);
boost::filesystem::last_write_time(ll_convert<std::wstring>(file_path), cur_time, ec);
}
#else
// file last write time

View File

@ -435,7 +435,7 @@ namespace tut
for (counter=0, foundUnused=false; !foundUnused; counter++ )
{
char counterStr[3];
sprintf(counterStr, "%02d", counter);
snprintf(counterStr, sizeof(counterStr), "%02d", counter);
uniqueDir = dirbase + counterStr;
foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) );
}

View File

@ -31,7 +31,9 @@
#include "llerror.h"
#include "llexception.h"
#if !LL_ARM64
jmp_buf LLImageJPEG::sSetjmpBuffer ;
#endif
LLImageJPEG::LLImageJPEG(S32 quality)
: LLImageFormatted(IMG_CODEC_JPEG),
mOutputBuffer( NULL ),
@ -78,12 +80,15 @@ bool LLImageJPEG::updateData()
//
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//except in the case of AARCH64/ARM64 where setjmp will crash
//
#if !LL_ARM64
if(setjmp(sSetjmpBuffer))
{
jpeg_destroy_decompress(&cinfo);
return false;
}
#endif
try
{
// Now we can initialize the JPEG decompression object.
@ -223,11 +228,13 @@ bool LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time)
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//
#if !LL_ARM64
if(setjmp(sSetjmpBuffer))
{
jpeg_destroy_decompress(&cinfo);
return true; // done
}
#endif
try
{
// Now we can initialize the JPEG decompression object.
@ -431,9 +438,10 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )
// Let the memory manager delete any temp files
jpeg_destroy(cinfo);
#if !LL_ARM64
// Return control to the setjmp point
longjmp(sSetjmpBuffer, 1) ;
#endif
}
// Decide whether to emit a trace or warning message.
@ -551,6 +559,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
//try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error
//so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao
//
#if !LL_ARM64
if( setjmp(sSetjmpBuffer) )
{
// If we get here, the JPEG code has signaled an error.
@ -561,7 +570,7 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )
mOutputBufferSize = 0;
return false;
}
#endif
try
{

View File

@ -78,7 +78,9 @@ protected:
S32 mEncodeQuality; // on a scale from 1 to 100
private:
#if !LL_ARM64
static jmp_buf sSetjmpBuffer; // To allow the library to abort.
#endif
};
#endif // LL_LLIMAGEJPEG_H

View File

@ -29,8 +29,6 @@
// this is defined so that we get static linking.
#include "openjpeg.h"
#include "event.h"
#include "cio.h"
// Factory function: see declaration in llimagej2c.cpp
LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl()
@ -48,6 +46,7 @@ std::string LLImageJ2COJ::getEngineInfo() const
#endif
}
#if WANT_VERBOSE_OPJ_SPAM
// Return string from message, eliminating final \n if present
static std::string chomp(const char* msg)
{
@ -63,27 +62,34 @@ static std::string chomp(const char* msg)
}
return message;
}
#endif
/**
sample error callback expecting a LLFILE* client object
*/
void error_callback(const char* msg, void*)
{
LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#endif
}
/**
sample warning callback expecting a LLFILE* client object
*/
void warning_callback(const char* msg, void*)
{
LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#endif
}
/**
sample debug callback expecting no client object
*/
void info_callback(const char* msg, void*)
{
LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#if WANT_VERBOSE_OPJ_SPAM
LL_INFOS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL;
#endif
}
// Divide a by 2 to the power of b and round upwards
@ -95,39 +101,13 @@ int ceildivpow2(int a, int b)
class JPEG2KBase
{
public:
JPEG2KBase() {}
JPEG2KBase() = default;
U8* buffer = nullptr;
OPJ_SIZE_T size = 0;
OPJ_OFF_T offset = 0;
};
#define WANT_VERBOSE_OPJ_SPAM LL_DEBUG
static void opj_info(const char* msg, void* user_data)
{
llassert(user_data);
#if WANT_VERBOSE_OPJ_SPAM
LL_INFOS("OpenJPEG") << msg << LL_ENDL;
#endif
}
static void opj_warn(const char* msg, void* user_data)
{
llassert(user_data);
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS("OpenJPEG") << msg << LL_ENDL;
#endif
}
static void opj_error(const char* msg, void* user_data)
{
llassert(user_data);
#if WANT_VERBOSE_OPJ_SPAM
LL_WARNS("OpenJPEG") << msg << LL_ENDL;
#endif
}
static OPJ_SIZE_T opj_read(void * buffer, OPJ_SIZE_T bytes, void* user_data)
{
llassert(user_data && buffer);
@ -283,11 +263,7 @@ public:
JPEG2KDecode(S8 discardLevel)
{
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
memset(&parameters, 0, sizeof(opj_dparameters_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
opj_set_default_decoder_parameters(&parameters);
parameters.cp_reduce = discardLevel;
}
@ -331,6 +307,11 @@ public:
decoder = opj_create_decompress(OPJ_CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_error_handler(decoder, error_callback, nullptr);
opj_set_warning_handler(decoder, warning_callback, nullptr);
opj_set_info_handler(decoder, info_callback, nullptr);
if (!opj_setup_decoder(decoder, &parameters))
{
return false;
@ -401,9 +382,9 @@ public:
decoder = opj_create_decompress(OPJ_CODEC_J2K);
opj_setup_decoder(decoder, &parameters);
opj_set_info_handler(decoder, opj_info, this);
opj_set_warning_handler(decoder, opj_warn, this);
opj_set_error_handler(decoder, opj_error, this);
opj_set_info_handler(decoder, info_callback, this);
opj_set_warning_handler(decoder, warning_callback, this);
opj_set_error_handler(decoder, error_callback, this);
if (stream)
{
@ -469,7 +450,6 @@ public:
private:
opj_dparameters_t parameters;
opj_event_mgr_t event_mgr;
opj_image_t* image = nullptr;
opj_codec_t* decoder = nullptr;
opj_stream_t* stream = nullptr;
@ -484,10 +464,6 @@ public:
JPEG2KEncode(const char* comment_text_in, bool reversible)
{
memset(&parameters, 0, sizeof(opj_cparameters_t));
memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
event_mgr.error_handler = error_callback;
event_mgr.warning_handler = warning_callback;
event_mgr.info_handler = info_callback;
opj_set_default_encoder_parameters(&parameters);
parameters.cod_format = OPJ_CODEC_J2K;
@ -555,6 +531,11 @@ public:
encoder = opj_create_compress(OPJ_CODEC_J2K);
/* catch events using our callbacks and give a local context */
opj_set_error_handler(encoder, error_callback, nullptr);
opj_set_warning_handler(encoder, warning_callback, nullptr);
opj_set_info_handler(encoder, info_callback, nullptr);
parameters.tcp_mct = (image->numcomps >= 3) ? 1 : 0; // no color transform for RGBA images
@ -578,10 +559,6 @@ public:
return false;
}
opj_set_info_handler(encoder, opj_info, this);
opj_set_warning_handler(encoder, opj_warn, this);
opj_set_error_handler(encoder, opj_error, this);
U32 width_tiles = (rawImageIn.getWidth() >> 6);
U32 height_tiles = (rawImageIn.getHeight() >> 6);
@ -786,7 +763,6 @@ public:
private:
opj_cparameters_t parameters;
opj_event_mgr_t event_mgr;
opj_image_t* image = nullptr;
opj_codec_t* encoder = nullptr;
opj_stream_t* stream = nullptr;

View File

@ -27,14 +27,6 @@ set(llkdu_HEADER_FILES
list(APPEND llkdu_SOURCE_FILES ${llkdu_HEADER_FILES})
# Our KDU package is built with KDU_X86_INTRINSICS in its .vcxproj file.
# Unless that macro is also set for every consumer build, KDU freaks out,
# spamming the viewer log with alignment FUD.
set_source_files_properties(${llkdu_SOURCE_FILES}
PROPERTIES
COMPILE_DEFINITIONS
"KDU_X86_INTRINSICS")
if (USE_KDU)
add_library (llkdu ${llkdu_SOURCE_FILES})
@ -42,10 +34,7 @@ if (USE_KDU)
target_include_directories( llkdu INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# Add tests
# ND: llkdu tests are very strange as they include stubs for KDU classes/methods
# if not having access to the right KDU version this test will fail to compile, incidentally I do not
# have access to a matching version of KDU and thus cannot get this tests to compile
if (LL_TESTS_KDU)
if (LL_TESTS)
include(LLAddBuildTest)
include(Tut)
SET(llkdu_TEST_SOURCE_FILES
@ -62,6 +51,6 @@ if (USE_KDU)
set_property( SOURCE ${llkdu_TEST_SOURCE_FILES} PROPERTY LL_TEST_ADDITIONAL_INCLUDE_DIRS ${llimage_include_dir})
LL_ADD_PROJECT_UNIT_TESTS(llkdu "${llkdu_TEST_SOURCE_FILES}")
endif (LL_TESTS_KDU)
endif (LL_TESTS)
endif (USE_KDU)

View File

@ -163,6 +163,7 @@ private:
S32 mNumComponents;
bool mUseYCC;
kdu_dims mDims;
kdu_push_pull_params mParams;
kdu_sample_allocator mAllocator;
kdu_tile_comp mComps[4];
kdu_line_buf mLines[4];
@ -255,7 +256,7 @@ LLImageJ2CKDU::LLImageJ2CKDU() : LLImageJ2CImpl(),
mCodeStreamp(),
mTPosp(),
mTileIndicesp(),
mRawImagep(NULL),
mRawImagep(nullptr),
mDecodeState(),
mBlocksSize(-1),
mPrecinctsSize(-1),
@ -295,17 +296,17 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod
// two U32s and a pointer, so it's not as if it would be a huge overhead
// to allocate a new one every time.
// Also -- why is base.getData() tested specifically here? If that returns
// NULL, shouldn't we bail out of the whole method?
// nullptr, shouldn't we bail out of the whole method?
if (!mInputp && base.getData())
{
// The compressed data has been loaded
// Setup the source for the codestream
mInputp.reset(new LLKDUMemSource(base.getData(), data_size));
mInputp = std::make_unique<LLKDUMemSource>(base.getData(), data_size);
}
if (mInputp)
{
// This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset().
// This is LLKDUMemSource::reset(), not std::unique_ptr::reset().
mInputp->reset();
}
@ -315,7 +316,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod
// *TODO: This seems to be wrong. The base class should have no idea of
// how j2c compression works so no good way of computing what's the byte
// range to be used.
mCodeStreamp->set_max_bytes(max_bytes, true);
mCodeStreamp->set_max_bytes(max_bytes);
// If you want to flip or rotate the image for some reason, change
// the resolution, or identify a restricted region of interest, this is
@ -461,8 +462,8 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
mCodeStreamp->change_appearance(false, true, false);
// Apply loading discard level and cropping if required
kdu_dims* region_kdu = NULL;
if (region != NULL)
kdu_dims* region_kdu = nullptr;
if (region != nullptr)
{
region_kdu = new kdu_dims;
region_kdu->pos.x = region[0];
@ -479,7 +480,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
if (region_kdu)
{
delete region_kdu;
region_kdu = NULL;
region_kdu = nullptr;
}
// Resize raw_image according to the image to be decoded
@ -490,12 +491,12 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
if (!mTileIndicesp)
{
mTileIndicesp.reset(new kdu_dims);
mTileIndicesp = std::make_unique<kdu_dims>();
}
mCodeStreamp->get_valid_tiles(*mTileIndicesp);
if (!mTPosp)
{
mTPosp.reset(new kdu_coords);
mTPosp = std::make_unique<kdu_coords>();
mTPosp->y = 0;
mTPosp->x = 0;
}
@ -505,7 +506,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
base.setLastError(msg.what());
return false;
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -596,8 +597,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
kdu_coords offset = tile_dims.pos - dims.pos;
int row_gap = channels*dims.size.x; // inter-row separation
kdu_byte *buf = buffer + offset.y*row_gap + offset.x*channels;
mDecodeState.reset(new LLKDUDecodeState(tile, buf, row_gap,
mCodeStreamp.get()));
mDecodeState = std::make_unique<LLKDUDecodeState>(tile, buf, row_gap, mCodeStreamp.get());
}
// Do the actual processing
F32 remaining_time = limit_time ? decode_time - decode_timer.getElapsedTimeF32().value() : 0.0f;
@ -622,7 +622,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco
cleanupCodeStream();
return true; // done
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -831,7 +831,7 @@ bool LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co
base.setLastError(msg.what());
return false;
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -865,7 +865,7 @@ bool LLImageJ2CKDU::getMetadata(LLImageJ2C &base)
base.setLastError(msg.what());
return false;
}
catch (kdu_exception kdu_value)
catch (const kdu_exception& kdu_value)
{
// KDU internally throws kdu_exception. It's possible that such an
// exception might leak out into our code. Catch kdu_exception
@ -997,8 +997,8 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
//std::cout << "Parsing discard level = " << discard_level << std::endl;
// Create the input codestream object.
setupCodeStream(base, true, MODE_FAST);
mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, NULL);
mCodeStreamp->set_max_bytes(KDU_LONG_MAX,true);
mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, nullptr);
mCodeStreamp->set_max_bytes(KDU_LONG_MAX,false);
siz_params *siz_in = mCodeStreamp->access_siz();
// Create the output codestream object.
@ -1094,8 +1094,10 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)
void set_default_colour_weights(kdu_params *siz)
{
kdu_params *enc = siz->access_cluster(ENC_params);
assert(enc != nullptr);
kdu_params *cod = siz->access_cluster(COD_params);
assert(cod != NULL);
assert(cod != nullptr);
bool can_use_ycc = true;
bool rev0 = false;
@ -1132,7 +1134,7 @@ void set_default_colour_weights(kdu_params *siz)
return;
}
float weight;
if (cod->get(Clev_weights,0,0,weight) || cod->get(Cband_weights,0,0,weight))
if (enc->get(Clev_weights,0,0,weight) || enc->get(Cband_weights,0,0,weight))
{
// Weights already specified explicitly -> nothing to do
return;
@ -1141,17 +1143,16 @@ void set_default_colour_weights(kdu_params *siz)
// These example weights are adapted from numbers generated by Marcus Nadenau
// at EPFL, for a viewing distance of 15 cm and a display resolution of
// 300 DPI.
cod->parse_string("Cband_weights:C0="
enc->parse_string("Cband_weights:C0="
"{0.0901},{0.2758},{0.2758},"
"{0.7018},{0.8378},{0.8378},{1}");
cod->parse_string("Cband_weights:C1="
enc->parse_string("Cband_weights:C1="
"{0.0263},{0.0863},{0.0863},"
"{0.1362},{0.2564},{0.2564},"
"{0.3346},{0.4691},{0.4691},"
"{0.5444},{0.6523},{0.6523},"
"{0.7078},{0.7797},{0.7797},{1}");
cod->parse_string("Cband_weights:C2="
enc->parse_string("Cband_weights:C2="
"{0.0773},{0.1835},{0.1835},"
"{0.2598},{0.4130},{0.4130},"
"{0.5040},{0.6464},{0.6464},"
@ -1170,7 +1171,7 @@ byte buffer, spacing successive output samples apart by `gap' bytes
all necessary level shifting, type conversion, rounding and truncation. */
{
int width = src.get_width();
if (src.get_buf32() != NULL)
if (src.get_buf32() != nullptr)
{ // Decompressed samples have a 32-bit representation (integer or float)
assert(precision >= 8); // Else would have used 16 bit representation
kdu_sample32 *sp = src.get_buf32();
@ -1333,11 +1334,11 @@ LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap,
mLines[c].pre_create(&mAllocator,mDims.size.x,mReversible[c],use_shorts,0,0);
if (res.which() == 0) // No DWT levels used
{
mEngines[c] = kdu_decoder(res.access_subband(LL_BAND),&mAllocator,use_shorts);
mEngines[c] = kdu_decoder(res.access_subband(LL_BAND), &mAllocator, mParams, use_shorts);
}
else
{
mEngines[c] = kdu_synthesis(res,&mAllocator,use_shorts);
mEngines[c] = kdu_synthesis(res, &mAllocator, mParams, use_shorts);
}
}
mAllocator.finalize(*codestreamp); // Actually creates buffering resources
@ -1415,7 +1416,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod
this->codestream = codestream;
codestream.get_valid_tiles(valid_tile_indices);
tile_idx = valid_tile_indices.pos;
tile = codestream.open_tile(tile_idx,NULL);
tile = codestream.open_tile(tile_idx, nullptr);
// Set up the individual components
num_components = codestream.get_num_components(true);
@ -1424,7 +1425,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod
kdc_component_flow_control *comp = components;
for (n = 0; n < num_components; n++, comp++)
{
comp->line = NULL;
comp->line = nullptr;
comp->reader = img_in;
kdu_coords subsampling;
codestream.get_subsampling(n,subsampling,true);
@ -1441,12 +1442,12 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod
assert(num_components >= 0);
tile.set_components_of_interest(num_components);
max_buffer_memory = engine.create(codestream,tile,false,NULL,false,1,NULL,NULL,false);
max_buffer_memory = engine.create(codestream, tile, false, nullptr, false, 1, nullptr, nullptr,false);
}
kdc_flow_control::~kdc_flow_control()
{
if (components != NULL)
if (components != nullptr)
{
delete[] components;
}
@ -1473,8 +1474,8 @@ bool kdc_flow_control::advance_components()
if (comp->ratio_counter < 0)
{
found_line = true;
comp->line = engine.exchange_line(n,NULL,NULL);
assert(comp->line != NULL);
comp->line = engine.exchange_line(n,nullptr,nullptr);
assert(comp->line != nullptr);
if (comp->line->get_width())
{
comp->reader->get(n,*(comp->line),0);
@ -1501,9 +1502,9 @@ void kdc_flow_control::process_components()
assert(comp->ratio_counter >= 0);
assert(comp->remaining_lines > 0);
comp->remaining_lines--;
assert(comp->line != NULL);
engine.exchange_line(n,comp->line,NULL);
comp->line = NULL;
assert(comp->line != nullptr);
engine.exchange_line(n,comp->line,nullptr);
comp->line = nullptr;
}
}
}

View File

@ -27,12 +27,13 @@
#ifndef LL_LLIMAGEJ2CKDU_H
#define LL_LLIMAGEJ2CKDU_H
#include "llpreprocessor.h"
#include "llimagej2c.h"
//
// KDU core header files
//
#define KDU_NO_THREADS
#include "kdu_elementary.h"
#include "kdu_messaging.h"
#include "kdu_params.h"
@ -41,7 +42,6 @@
#include "include_kdu_xxxx.h"
#include "kdu_sample_processing.h"
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
class LLKDUDecodeState;

View File

@ -27,9 +27,9 @@
#ifndef LL_LLKDUMEM_H
#define LL_LLKDUMEM_H
// Support classes for reading and writing from memory buffers in KDU
#define KDU_NO_THREADS
#include "llpreprocessor.h"
// Support classes for reading and writing from memory buffers in KDU
#define kdu_xxxx "kdu_image.h"
#include "include_kdu_xxxx.h"
@ -54,9 +54,7 @@ public:
mCurPos = 0;
}
~LLKDUMemSource()
{
}
~LLKDUMemSource() = default;
int read(kdu_core::kdu_byte *buf, int num_bytes)
{
@ -94,9 +92,7 @@ public:
mOutputSize = &output_size;
}
~LLKDUMemTarget()
{
}
~LLKDUMemTarget() = default;
bool write(const kdu_core::kdu_byte *buf, int num_bytes)
{

View File

@ -139,18 +139,19 @@ int kdu_tile_comp::get_bit_depth(bool ) { return 8; }
bool kdu_tile_comp::get_reversible() { return false; }
int kdu_tile_comp::get_num_resolutions() { return 1; }
kdu_subband kdu_resolution::access_subband(int ) { kdu_subband a; return a; }
void kdu_resolution::get_dims(kdu_dims& ) { }
int kdu_resolution::which() { return 0; }
int kdu_resolution::get_valid_band_indices(int &) { return 1; }
kdu_synthesis::kdu_synthesis(kdu_resolution, kdu_sample_allocator*, bool, float, kdu_thread_env*, kdu_thread_queue*) { }
void kdu_resolution::get_dims(kdu_dims& ) const { }
int kdu_resolution::which() const { return 0; }
int kdu_resolution::get_valid_band_indices(int &) const { return 1; }
kdu_synthesis::kdu_synthesis(kdu_resolution, kdu_sample_allocator*, kdu_push_pull_params&, bool, float, kdu_thread_env*, kdu_thread_queue*) { }
//kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool) { }
kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool, kd_core_local::kd_coremem*) {}
kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool) {}
kdu_params::~kdu_params() { }
void kdu_params::destroy() { }
void kdu_params::set(const char* , int , int , bool ) { }
void kdu_params::set(const char* , int , int , int ) { }
void kdu_params::finalize_all(bool ) { }
void kdu_params::finalize_all(int, bool ) { }
void kdu_params::copy_from(kdu_params*, int, int, int, int, int, bool, bool, bool) { }
void kdu_params::copy_from(kdu_params*, int, int, int, int, int, bool, bool, bool, bool) { }
bool kdu_params::parse_string(const char*) { return false; }
bool kdu_params::get(const char*, int, int, bool&, bool, bool, bool) { return false; }
bool kdu_params::get(const char*, int, int, float&, bool, bool, bool) { return false; }
@ -159,13 +160,13 @@ kdu_params* kdu_params::access_relation(int, int, int, bool) { return NULL; }
kdu_params* kdu_params::access_cluster(const char*) { return NULL; }
void kdu_codestream::set_fast() { }
void kdu_codestream::set_fussy() { }
void kdu_codestream::get_dims(int, kdu_dims&, bool ) { }
void kdu_codestream::get_dims(int, kdu_dims&, bool ) const { }
int kdu_codestream::get_min_dwt_levels() { return 5; }
int kdu_codestream::get_max_tile_layers() { return 1; }
void kdu_codestream::change_appearance(bool, bool, bool, kdu_thread_env *) {}
void kdu_codestream::get_tile_dims(kdu_coords, int, kdu_dims&, bool ) { }
void kdu_codestream::destroy() { }
void kdu_codestream::collect_timing_stats(int ) { }
void kdu_codestream::collect_timing_stats(int ) const { }
void kdu_codestream::set_max_bytes(kdu_long, bool, bool ) { }
void kdu_codestream::get_valid_tiles(kdu_dims& ) { }
void kdu_codestream::create(
@ -182,19 +183,21 @@ void kdu_codestream::get_subsampling(int , kdu_coords&, bool ) { }
void kdu_codestream::flush(kdu_long *, int, kdu_uint16 *, bool, bool, double, kdu_thread_env*, int) { }
void kdu_codestream::set_resilient(bool ) { }
int kdu_codestream::get_num_components(bool ) { return 0; }
kdu_long kdu_codestream::get_total_bytes(bool ) { return 0; }
kdu_long kdu_codestream::get_total_bytes(bool ) const { return 0; }
kdu_long kdu_codestream::get_compressed_data_memory(bool ) const {return 0; }
void kdu_codestream::share_buffering(kdu_codestream ) { }
int kdu_codestream::get_num_tparts() { return 0; }
int kdu_codestream::get_num_tparts() const { return 0; }
int kdu_codestream::trans_out(kdu_long, kdu_long*, int, bool, kdu_thread_env* ) { return 0; }
bool kdu_codestream::ready_for_flush(kdu_thread_env*) { return false; }
siz_params* kdu_codestream::access_siz() { return NULL; }
kdu_tile kdu_codestream::open_tile(kdu_coords , kdu_thread_env* ) { kdu_tile a; return a; }
kdu_codestream_comment kdu_codestream::add_comment(kdu_thread_env*) { kdu_codestream_comment a; return a; }
kdu_codestream_comment kdu_codestream::get_comment(kdu_codestream_comment) { kdu_codestream_comment a; return a; };
void kdu_subband::close_block(kdu_block*, kdu_thread_env*) { }
void kdu_subband::get_valid_blocks(kdu_dims &indices) const { }
kdu_block * kdu_subband::open_block(kdu_coords, int *, kdu_thread_env *, int, bool) { return NULL; }
bool kdu_codestream_comment::put_text(const char*) { return false; }
const char *kdu_codestream_comment::get_text() { return nullptr; };
void kdu_customize_warnings(kdu_message*) { }
void kdu_customize_errors(kdu_message*) { }
kdu_long kdu_multi_analysis::create(
@ -209,16 +212,18 @@ kdu_long kdu_multi_analysis::create(
const kdu_push_pull_params*,
kdu_membroker*) { return kdu_long(0); }
void kdu_multi_analysis::destroy(kdu_thread_env *) {}
siz_params::siz_params() : kdu_params(NULL, false, false, false, false, false) { }
siz_params::siz_params(kd_core_local::kd_coremem*) : kdu_params(NULL, false, false, false, false, false) { }
siz_params::~siz_params() {}
void siz_params::finalize(bool ) { }
void siz_params::copy_with_xforms(kdu_params*, int, int, bool, bool, bool) { }
int siz_params::write_marker_segment(kdu_output*, kdu_params*, int) { return 0; }
int siz_params::write_marker_segment(kdu_output*, kdu_params*, int, int&) { return 0; }
bool siz_params::check_marker_segment(kdu_uint16, int, kdu_byte a[], int&) { return false; }
bool siz_params::read_marker_segment(kdu_uint16, int, kdu_byte a[], int) { return false; }
int siz_params::read_marker_segment(kdu_uint16 code, int num_bytes, kdu_byte bytes[], int tpart_idx) { return false; }
kdu_decoder::kdu_decoder(
kdu_subband subband,
kdu_sample_allocator*,
kdu_push_pull_params&,
bool, float, int,
kdu_thread_env*,
kdu_thread_queue*,

View File

@ -6,6 +6,7 @@ include(00-Common)
include(LLCommon)
include(bugsplat)
include(Boost)
include(SSE2NEON)
set(llmath_SOURCE_FILES
llbbox.cpp
@ -59,6 +60,7 @@ set(llmath_HEADER_FILES
llmath.h
llmatrix3a.h
llmatrix3a.inl
llmatrix4a.h
llmodularmath.h
lloctree.h
llperlin.h
@ -99,7 +101,7 @@ list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES})
add_library (llmath ${llmath_SOURCE_FILES})
target_link_libraries(llmath llcommon llmeshoptimizer)
target_link_libraries(llmath llcommon llmeshoptimizer ll::sse2neon)
target_include_directories( llmath INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
# Add tests

View File

@ -95,6 +95,10 @@ private:
bool mEmpty; // Nothing has been added to this bbox yet
};
static_assert(std::is_trivially_copyable<LLBBox>::value, "LLBBox must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLBBox>::value, "LLBBox must be trivial move");
static_assert(std::is_standard_layout<LLBBox>::value, "LLBBox must be a standard layout type");
//LLBBox operator*(const LLBBox &a, const LLMatrix4 &b);

View File

@ -61,5 +61,8 @@ private:
LLBBoxLocal operator*(const LLBBoxLocal &a, const LLMatrix4 &b);
static_assert(std::is_trivially_copyable<LLBBoxLocal>::value, "LLBBoxLocal must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLBBoxLocal>::value, "LLBBoxLocal must be trivial move");
static_assert(std::is_standard_layout<LLBBoxLocal>::value, "LLBBoxLocal must be a standard layout type");
#endif // LL_BBOXLOCAL_H

View File

@ -40,7 +40,7 @@ class LLLine
public:
LLLine();
LLLine( const LLVector3& first_point, const LLVector3& second_point );
virtual ~LLLine() {};
~LLLine() = default;
void setPointDirection( const LLVector3& first_point, const LLVector3& second_point );
void setPoints( const LLVector3& first_point, const LLVector3& second_point );
@ -76,5 +76,8 @@ protected:
LLVector3 mDirection;
};
static_assert(std::is_trivially_copyable<LLLine>::value, "LLLine must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLLine>::value, "LLLine must be trivial move");
static_assert(std::is_standard_layout<LLLine>::value, "LLLine must be a standard layout type");
#endif

View File

@ -56,7 +56,7 @@ public:
//////////////////////////
// Ctor
LLMatrix3a() {}
LLMatrix3a() = default;
// Ctor for setting by columns
inline LLMatrix3a( const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2 );
@ -115,14 +115,18 @@ protected:
};
static_assert(std::is_trivial<LLMatrix3a>::value, "LLMatrix3a must be a trivial type");
class LLRotation : public LLMatrix3a
{
public:
LLRotation() {}
LLRotation() = default;
// Returns true if this rotation is orthonormal with det ~= 1
inline bool isOkRotation() const;
};
static_assert(std::is_trivial<LLRotation>::value, "LLRotation must be a trivial type");
#endif

View File

@ -36,10 +36,7 @@ class LLMatrix4a
public:
LL_ALIGN_16(LLVector4a mMatrix[4]);
LLMatrix4a()
{
}
LLMatrix4a() = default;
explicit LLMatrix4a(const LLMatrix4& val)
{
@ -228,6 +225,8 @@ public:
const LLVector4a& getTranslation() const { return mMatrix[3]; }
};
static_assert(std::is_trivial<LLMatrix4a>::value, "LLMatrix4a must be a trivial type");
inline LLVector4a rowMul(const LLVector4a &row, const LLMatrix4a &mat)
{
LLVector4a result;

View File

@ -43,7 +43,7 @@ class LLPlane
public:
// Constructors
LLPlane() {}; // no default constructor
LLPlane() = default;
LLPlane(const LLVector3 &p0, F32 d) { setVec(p0, d); }
LLPlane(const LLVector3 &p0, const LLVector3 &n) { setVec(p0, n); }
inline void setVec(const LLVector3 &p0, F32 d) { mV.set(p0[0], p0[1], p0[2], d); }
@ -104,6 +104,7 @@ private:
LLVector4a mV;
} LL_ALIGN_POSTFIX(16);
static_assert(std::is_trivial<LLPlane>::value, "LLPlane must be a trivial type");
#endif // LL_LLPLANE_H

View File

@ -174,6 +174,10 @@ public:
//static U32 mMultCount;
};
static_assert(std::is_trivially_copyable<LLQuaternion>::value, "LLQuaternion must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLQuaternion>::value, "LLQuaternion must be trivial move");
static_assert(std::is_standard_layout<LLQuaternion>::value, "LLQuaternion must be a standard layout type");
inline LLSD LLQuaternion::getValue() const
{
LLSD ret;

View File

@ -49,7 +49,7 @@ public:
//////////////////////////
// Ctor
LLQuaternion2() {}
LLQuaternion2() = default;
// Ctor from LLQuaternion
explicit LLQuaternion2( const class LLQuaternion& quat );
@ -102,4 +102,6 @@ protected:
};
static_assert(std::is_trivial<LLQuaternion2>::value, "LLQuaternion2 must be a trivial type");
#endif

View File

@ -51,10 +51,6 @@ public:
LLRectBase(): mLeft(0), mTop(0), mRight(0), mBottom(0)
{}
LLRectBase(const LLRectBase &r):
mLeft(r.mLeft), mTop(r.mTop), mRight(r.mRight), mBottom(r.mBottom)
{}
LLRectBase(Type left, Type top, Type right, Type bottom):
mLeft(left), mTop(top), mRight(right), mBottom(bottom)
{}
@ -295,4 +291,8 @@ template <class Type> LLRectBase<Type> LLRectBase<Type>::null(0,0,0,0);
typedef LLRectBase<S32> LLRect;
typedef LLRectBase<F32> LLRectf;
static_assert(std::is_trivially_copyable<LLRect>::value, "LLRect must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLRect>::value, "LLRect must be trivial move");
static_assert(std::is_standard_layout<LLRect>::value, "LLRect must be a standard layout type");
#endif

View File

@ -31,16 +31,26 @@
#error "Please include llmath.h before this file."
#endif
#if ( ( LL_DARWIN || LL_LINUX ) && !(__SSE2__) ) || ( LL_WINDOWS && ( _M_IX86_FP < 2 && ADDRESS_SIZE == 32 ) )
#error SSE2 not enabled. LLVector4a and related class will not compile.
// the check for this error case must be split into multiple parts
// because some versions of VS complain about '__SSE2__'
#if ( ( LL_DARWIN || LL_LINUX ) )
#if !(__SSE2__) && !(__arm64__) && !(__aarch64__)
#error SSE2 not enabled. LLVector4a and related class will not compile.
#endif
#elif ( LL_WINDOWS && ( _M_IX86_FP < 2 && ADDRESS_SIZE == 32 ) )
#error SSE2 not enabled. LLVector4a and related class will not compile.
#endif
#if !LL_WINDOWS
#include <stdint.h>
#endif
#if defined(__arm64__) || defined(__aarch64__)
#include "sse2neon.h"
#else
#include <xmmintrin.h>
#include <emmintrin.h>
#endif
#include "llmemory.h"
#include "llsimdtypes.h"

View File

@ -36,7 +36,7 @@ typedef __m128 LLQuad;
class LLBool32
{
public:
inline LLBool32() {}
inline LLBool32() = default;
inline LLBool32(int rhs) : m_bool(rhs) {}
inline LLBool32(unsigned int rhs) : m_bool(rhs) {}
inline LLBool32(bool rhs) { m_bool = static_cast<const int>(rhs); }
@ -46,13 +46,15 @@ public:
inline operator bool() const { return static_cast<const bool&>(m_bool); }
private:
int m_bool{ 0 };
int m_bool;
};
static_assert(std::is_trivial<LLBool32>::value, "LLBool32 must be a standard layout type");
class LLSimdScalar
{
public:
inline LLSimdScalar() {}
inline LLSimdScalar() = default;
inline LLSimdScalar(LLQuad q)
{
mQ = q;
@ -100,7 +102,9 @@ public:
}
private:
LLQuad mQ{};
LLQuad mQ;
};
static_assert(std::is_trivial<LLSimdScalar>::value, "LLSimdScalar must be a standard layout type");
#endif //LL_SIMD_TYPES_H

View File

@ -95,10 +95,7 @@ public:
////////////////////////////////////
//LLVector4a is plain data which should never have a default constructor or destructor(malloc&free won't trigger it)
LLVector4a()
{ //DO NOT INITIALIZE -- The overhead is completely unnecessary
ll_assert_aligned(this,16);
}
LLVector4a() = default;
LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)
{
@ -361,8 +358,6 @@ public:
////////////////////////////////////
// Do NOT add aditional operators without consulting someone with SSE experience
inline const LLVector4a& operator= ( const LLVector4a& rhs );
inline const LLVector4a& operator= ( const LLQuad& rhs );
inline operator LLQuad() const;
@ -378,9 +373,11 @@ public:
};
private:
LLQuad mQ{};
LLQuad mQ;
};
static_assert(std::is_trivial<LLVector4a>::value, "LLVector4a must be a trivial type");
inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)
{
min.setMin(min, p);

View File

@ -115,7 +115,7 @@ inline void LLVector4a::set(F32 x, F32 y, F32 z, F32 w)
// Set to all zeros
inline void LLVector4a::clear()
{
mQ = LLVector4a::getZero().mQ;
mQ = _mm_setzero_ps();
}
inline void LLVector4a::splat(const F32 x)
@ -272,6 +272,9 @@ inline void LLVector4a::setCross3(const LLVector4a& a, const LLVector4a& b)
// Set all elements to the dot product of the x, y, and z elements in a and b
inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)
{
#if (defined(__arm64__) || defined(__aarch64__))
mQ = _mm_dp_ps(a.mQ, b.mQ, 0x7f);
#else
// ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
// yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
@ -284,11 +287,15 @@ inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)
const __m128i zSplat = _mm_shuffle_epi32(_mm_castps_si128(ab), _MM_SHUFFLE( 2, 2, 2, 2 ));
// mQ = { a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
mQ = _mm_add_ps(_mm_castsi128_ps(zSplat), xPlusYSplat);
#endif
}
// Set all elements to the dot product of the x, y, z, and w elements in a and b
inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)
{
#if (defined(__arm64__) || defined(__aarch64__))
mQ = _mm_dp_ps(a.mQ, b.mQ, 0xff);
#else
// ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }
const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );
// yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] }
@ -301,21 +308,29 @@ inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)
// mQ = { a[W]*b[W] + a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }
mQ = _mm_add_ps(xPlusYSplat, zPlusWSplat);
#endif
}
// Return the 3D dot product of this vector and b
inline LLSimdScalar LLVector4a::dot3(const LLVector4a& b) const
{
#if (defined(__arm64__) || defined(__aarch64__))
return _mm_dp_ps(mQ, b.mQ, 0x7f);
#else
const LLQuad ab = _mm_mul_ps( mQ, b.mQ );
const LLQuad splatY = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(1, 1, 1, 1) ) );
const LLQuad splatZ = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(2, 2, 2, 2) ) );
const LLQuad xPlusY = _mm_add_ps( ab, splatY );
return _mm_add_ps( xPlusY, splatZ );
#endif
}
// Return the 4D dot product of this vector and b
inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const
{
#if (defined(__arm64__) || defined(__aarch64__))
return _mm_dp_ps(mQ, b.mQ, 0xff);
#else
// ab = { w, z, y, x }
const LLQuad ab = _mm_mul_ps( mQ, b.mQ );
// upperProdsInLowerElems = { y, x, y, x }
@ -325,6 +340,7 @@ inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const
// shuffled = { z+x, z+x, z+x, z+x }
const LLQuad shuffled = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128( sumOfPairs ), _MM_SHUFFLE(1, 1, 1, 1) ) );
return _mm_add_ss( sumOfPairs, shuffled );
#endif
}
// Normalize this vector with respect to the x, y, and z components only. Accurate to 22 bites of precision. W component is destroyed
@ -593,12 +609,6 @@ inline bool LLVector4a::equals3(const LLVector4a& rhs, F32 tolerance ) const
////////////////////////////////////
// Do NOT add aditional operators without consulting someone with SSE experience
inline const LLVector4a& LLVector4a::operator= ( const LLVector4a& rhs )
{
mQ = rhs.mQ;
return *this;
}
inline const LLVector4a& LLVector4a::operator= ( const LLQuad& rhs )
{
mQ = rhs;

View File

@ -61,7 +61,7 @@ public:
};
// Empty default ctor
LLVector4Logical() {}
LLVector4Logical() = default;
LLVector4Logical( const LLQuad& quad )
{
@ -120,7 +120,9 @@ public:
private:
LLQuad mQ{};
LLQuad mQ;
};
static_assert(std::is_trivial<LLVector4Logical>::value, "LLVector4Logical must be a standard layout type");
#endif //LL_VECTOR4ALOGICAL_H

View File

@ -142,6 +142,10 @@ class LLMatrix3
friend std::ostream& operator<<(std::ostream& s, const LLMatrix3 &a); // Stream a
};
static_assert(std::is_trivially_copyable<LLMatrix3>::value, "LLMatrix3 must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLMatrix3>::value, "LLMatrix3 must be trivial move");
static_assert(std::is_standard_layout<LLMatrix3>::value, "LLMatrix3 must be a standard layout type");
inline LLMatrix3::LLMatrix3(void)
{
mMatrix[0][0] = 1.f;

View File

@ -156,10 +156,6 @@ LLMatrix4::LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw)
mMatrix[3][3] = 1.f;
}
LLMatrix4::~LLMatrix4(void)
{
}
// Clear and Assignment Functions
const LLMatrix4& LLMatrix4::setZero()

View File

@ -119,8 +119,6 @@ public:
const LLVector4 &pos); // Initializes Matrix with Euler angles
LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw); // Initializes Matrix with Euler angles
~LLMatrix4(void); // Destructor
LLSD getValue() const;
void setValue(const LLSD&);
@ -242,6 +240,10 @@ public:
friend std::ostream& operator<<(std::ostream& s, const LLMatrix4 &a); // Stream a
};
static_assert(std::is_trivially_copyable<LLMatrix4>::value, "LLMatrix4 must be trivial copy");
static_assert(std::is_trivially_move_assignable<LLMatrix4>::value, "LLMatrix4 must be trivial move");
static_assert(std::is_standard_layout<LLMatrix4>::value, "LLMatrix4 must be a standard layout type");
inline const LLMatrix4& LLMatrix4::setIdentity()
{
mMatrix[0][0] = 1.f;

Some files were not shown because too many files have changed in this diff Show More