From 795cf604ea155892c9d98fd342d9b6fe75b461f6 Mon Sep 17 00:00:00 2001 From: Rye Date: Tue, 14 Oct 2025 07:31:47 -0400 Subject: Fix or supress various warnings under GCC builds Signed-off-by: Rye --- indra/llmath/llcalc.cpp | 11 ----------- indra/llmath/llcalc.h | 7 +------ indra/llmath/llcalcparser.h | 18 +++++++++++++++--- indra/llmath/llvolume.cpp | 2 ++ 4 files changed, 18 insertions(+), 20 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llcalc.cpp b/indra/llmath/llcalc.cpp index e060b5df58..311e1e7059 100644 --- a/indra/llmath/llcalc.cpp +++ b/indra/llmath/llcalc.cpp @@ -116,17 +116,6 @@ void LLCalc::clearAllVariables() mVariables.clear(); } -/* -void LLCalc::updateVariables(LLSD& vars) -{ - LLSD::map_iterator cIt = vars.beginMap(); - for(; cIt != vars.endMap(); cIt++) - { - setVar(cIt->first, (F32)(LLSD::Real)cIt->second); - } -} -*/ - bool LLCalc::evalString(const std::string& expression, F32& result) { std::string expr_upper = expression; diff --git a/indra/llmath/llcalc.h b/indra/llmath/llcalc.h index 09672eb13b..14797de996 100644 --- a/indra/llmath/llcalc.h +++ b/indra/llmath/llcalc.h @@ -73,10 +73,9 @@ public: void setVar(const std::string& name, const F32& value); void clearVar(const std::string& name); void clearAllVariables(); -// void updateVariables(LLSD& vars); bool evalString(const std::string& expression, F32& result); - std::string::size_type getLastErrorPos() { return mLastErrorPos; } + std::string::size_type getLastErrorPos() const { return mLastErrorPos; } static LLCalc* getInstance(); static void cleanUp(); @@ -89,10 +88,6 @@ private: calc_map_t mConstants; calc_map_t mVariables; - // *TODO: Add support for storing user defined variables, and stored functions. - // Will need UI work, and a means to save them between sessions. -// calc_map_t mUserVariables; - // "There shall be only one" static LLCalc* sInstance; }; diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h index ea71752ebc..fe4e6bb1a4 100644 --- a/indra/llmath/llcalcparser.h +++ b/indra/llmath/llcalcparser.h @@ -27,6 +27,13 @@ #ifndef LL_CALCPARSER_H #define LL_CALCPARSER_H +#include "llpreprocessor.h" + +#if defined(LL_GNUC) && GCC_VERSION >= 130000 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdangling-pointer" +#endif + #include #include #include @@ -35,6 +42,10 @@ #include using namespace boost::spirit::classic; +#if defined(LL_GNUC) && GCC_VERSION >= 130000 +# pragma GCC diagnostic pop +#endif + #include "llcalc.h" #include "llmath.h" @@ -131,14 +142,14 @@ struct LLCalcParser : grammar power = unary_expr[power.value = arg1] >> - *('^' >> assert_syntax(unary_expr[power.value = phoenix::bind(&powf)(power.value, arg1)])) + *('^' >> assert_syntax(unary_expr[power.value = phoenix::bind(&LLCalcParser::_pow)(self, power.value, arg1)])) ; term = power[term.value = arg1] >> *(('*' >> assert_syntax(power[term.value *= arg1])) | ('/' >> assert_syntax(power[term.value /= arg1])) | - ('%' >> assert_syntax(power[term.value = phoenix::bind(&fmodf)(term.value, arg1)])) + ('%' >> assert_syntax(power[term.value = phoenix::bind(&LLCalcParser::_fmod)(self, term.value, arg1)])) ) ; @@ -177,10 +188,11 @@ private: F32 _floor(const F32& a) const { return (F32)llfloor(a); } F32 _ceil(const F32& a) const { return (F32)llceil(a); } F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); } + F32 _pow(const F32& a, const F32& b) const { return powf(a, b); } + F32 _fmod(const F32&a, const F32& b) const { return fmodf(a, b); } LLCalc::calc_map_t* mConstants; LLCalc::calc_map_t* mVariables; -// LLCalc::calc_map_t* mUserVariables; F32& mResult; }; diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index b3cb278d59..dfad66040e 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2348,7 +2348,9 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) const LLSD::Binary& pos = mdl[i]["Position"].asBinary(); const LLSD::Binary& norm = mdl[i]["Normal"].asBinary(); +#if 0 // keep this code for now in case we decide to add support for on-the-wire tangents const LLSD::Binary& tangent = mdl[i]["Tangent"].asBinary(); +#endif const LLSD::Binary& tc = mdl[i]["TexCoord0"].asBinary(); const LLSD::Binary& idx = mdl[i]["TriangleList"].asBinary(); -- cgit v1.3 From 37f89080ba5ce1ddd7848d2029794a5f5aabb7be Mon Sep 17 00:00:00 2001 From: Rye Date: Thu, 23 Oct 2025 09:15:38 -0400 Subject: Introduce global precompiled header to accelerate build Signed-off-by: Rye --- indra/CMakeLists.txt | 3 ++ indra/cmake/LLAddBuildTest.cmake | 14 +++++++- indra/llappearance/CMakeLists.txt | 8 +++++ indra/llappearanceutility/CMakeLists.txt | 8 +++++ indra/llaudio/CMakeLists.txt | 4 +++ indra/llcharacter/CMakeLists.txt | 4 +++ indra/llcommon/CMakeLists.txt | 28 +++++++++++++--- indra/llcommon/llsd.cpp | 5 ++- indra/llcommon/llsdjson.cpp | 1 - indra/llcorehttp/CMakeLists.txt | 8 ++++- indra/llcrashlogger/CMakeLists.txt | 4 +++ indra/llfilesystem/CMakeLists.txt | 11 +++++++ indra/llimage/CMakeLists.txt | 4 +++ indra/llimagej2coj/CMakeLists.txt | 3 ++ indra/llinventory/CMakeLists.txt | 4 +++ indra/llmath/CMakeLists.txt | 8 +++-- indra/llmeshoptimizer/CMakeLists.txt | 4 +++ indra/llmessage/CMakeLists.txt | 4 +++ indra/llphysicsextensionsos/CMakeLists.txt | 4 +++ indra/llplugin/CMakeLists.txt | 5 +++ indra/llplugin/slplugin/CMakeLists.txt | 10 ++++++ indra/llprecompiled/CMakeLists.txt | 53 ++++++++++++++++++++++++++++++ indra/llprecompiled/cmake_dummy.cpp | 24 ++++++++++++++ indra/llprimitive/CMakeLists.txt | 4 +++ indra/llrender/CMakeLists.txt | 7 ++++ indra/llui/CMakeLists.txt | 4 +++ indra/llwindow/CMakeLists.txt | 15 +++++++++ indra/llxml/CMakeLists.txt | 3 ++ 28 files changed, 241 insertions(+), 13 deletions(-) create mode 100644 indra/llprecompiled/CMakeLists.txt create mode 100644 indra/llprecompiled/cmake_dummy.cpp (limited to 'indra/llmath') diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt index 571465c707..a7f0ab0486 100644 --- a/indra/CMakeLists.txt +++ b/indra/CMakeLists.txt @@ -58,6 +58,9 @@ endif (NOT CMAKE_BUILD_TYPE) add_subdirectory(cmake) +if (USE_PRECOMPILED_HEADERS) + add_subdirectory(${LIBS_OPEN_PREFIX}llprecompiled) +endif () add_subdirectory(${LIBS_OPEN_PREFIX}llaudio) add_subdirectory(${LIBS_OPEN_PREFIX}llappearance) add_subdirectory(${LIBS_OPEN_PREFIX}llcharacter) diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake index 83725ffd1b..4959051617 100644 --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -100,6 +100,10 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) ) endif(DARWIN) + if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(PROJECT_${project}_TEST_${name} REUSE_FROM llprecompiled) + endif () + # # Per-codefile additional / external project dep and lib dep property extraction # @@ -122,7 +126,9 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES COMPILE_FLAGS "${${name}_test_additional_CFLAGS}" - COMPILE_DEFINITIONS "LL_TEST=${name};LL_TEST_${name}") + COMPILE_DEFINITIONS "LL_TEST=${name};LL_TEST_${name}" + FOLDER "Tests" + ) if(LL_TEST_VERBOSE) message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_CFLAGS ${${name}_test_additional_CFLAGS}") endif() @@ -217,6 +223,7 @@ FUNCTION(LL_ADD_INTEGRATION_TEST PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}" COMPILE_DEFINITIONS "LL_TEST=${testname};LL_TEST_${testname}" + FOLDER "Tests" ) # The following was copied to llcorehttp/CMakeLists.txt's texture_load target. @@ -246,6 +253,11 @@ FUNCTION(LL_ADD_INTEGRATION_TEST target_link_libraries(INTEGRATION_TEST_${testname} ${libraries}) target_include_directories (INTEGRATION_TEST_${testname} PRIVATE ${LIBS_OPEN_DIR}/test ) + if (USE_PRECOMPILED_HEADERS) + target_include_directories (INTEGRATION_TEST_${testname} PRIVATE ${LIBS_OPEN_DIR}/llmath ) + target_precompile_headers(INTEGRATION_TEST_${testname} REUSE_FROM llprecompiled) + endif () + # Create the test running command set(test_command ${ARGN}) set(TEST_EXE $) diff --git a/indra/llappearance/CMakeLists.txt b/indra/llappearance/CMakeLists.txt index 40a1036597..5b6d68fa37 100644 --- a/indra/llappearance/CMakeLists.txt +++ b/indra/llappearance/CMakeLists.txt @@ -69,6 +69,10 @@ target_link_libraries(llappearance ) target_include_directories( llappearance INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llappearance REUSE_FROM llprecompiled) +endif () + if (BUILD_HEADLESS) add_library (llappearanceheadless ${llappearance_SOURCE_FILES}) target_include_directories( llappearanceheadless INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) @@ -85,4 +89,8 @@ if (BUILD_HEADLESS) llcorehttp llcommon ) + + if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llappearanceheadless REUSE_FROM llprecompiled) + endif () endif (BUILD_HEADLESS) diff --git a/indra/llappearanceutility/CMakeLists.txt b/indra/llappearanceutility/CMakeLists.txt index 1d4e5309ba..53b5ce1cbe 100644 --- a/indra/llappearanceutility/CMakeLists.txt +++ b/indra/llappearanceutility/CMakeLists.txt @@ -63,6 +63,10 @@ target_link_libraries(appearance-utility-bin llxml ) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(appearance-utility-bin REUSE_FROM llprecompiled) +endif () + if (BUILD_HEADLESS) add_executable(appearance-utility-headless-bin ${appearance_utility_SOURCE_FILES}) @@ -74,5 +78,9 @@ if (BUILD_HEADLESS) llrenderheadless llxml ) + + if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(appearance-utility-headless-bin REUSE_FROM llprecompiled) + endif () endif (BUILD_HEADLESS) diff --git a/indra/llaudio/CMakeLists.txt b/indra/llaudio/CMakeLists.txt index 9278d3c488..18e29fb194 100644 --- a/indra/llaudio/CMakeLists.txt +++ b/indra/llaudio/CMakeLists.txt @@ -54,3 +54,7 @@ endif() if( TARGET ll::fmodstudio ) target_link_libraries( llaudio ll::fmodstudio ) endif() + +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llaudio REUSE_FROM llprecompiled) +endif () diff --git a/indra/llcharacter/CMakeLists.txt b/indra/llcharacter/CMakeLists.txt index bc45eb474a..1f019e6aef 100644 --- a/indra/llcharacter/CMakeLists.txt +++ b/indra/llcharacter/CMakeLists.txt @@ -70,3 +70,7 @@ target_link_libraries( llfilesystem llxml ) + +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llcharacter REUSE_FROM llprecompiled) +endif () diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 2de9deea70..c3b892b204 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -68,7 +68,7 @@ set(llcommon_SOURCE_FILES llmetricperformancetester.cpp llmortician.cpp llmutex.cpp - llptrto.cpp + llptrto.cpp llpredicate.cpp llprocess.cpp llprocessor.cpp @@ -108,7 +108,7 @@ set(llcommon_SOURCE_FILES workqueue.cpp StackWalker.cpp ) - + set(llcommon_HEADER_FILES CMakeLists.txt @@ -255,14 +255,28 @@ set(llcommon_HEADER_FILES workqueue.h StackWalker.h ) - + if (DARWIN) list(APPEND llcommon_HEADER_FILES llsys_objc.h) list(APPEND llcommon_SOURCE_FILES llsys_objc.mm) + + set_source_files_properties( + llsys_objc.mm + PROPERTIES + SKIP_PRECOMPILE_HEADERS TRUE + ) endif (DARWIN) if (USE_TRACY) list(APPEND llcommon_SOURCE_FILES llprofiler.cpp) + + # Skip precompiled headers on these files due to special compilation needs + set_source_files_properties( + llfasttimer.cpp + llprofiler.cpp + PROPERTIES + SKIP_PRECOMPILE_HEADERS TRUE + ) endif () list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES}) @@ -280,8 +294,12 @@ target_link_libraries( ll::sse2neon ) -target_include_directories(llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(llcommon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(llcommon PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(llcommon PRIVATE ${CMAKE_SOURCE_DIR}/llmath) + +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llcommon REUSE_FROM llprecompiled) +endif () add_dependencies(llcommon stage_third_party_libs) diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 77fe545c3f..ea6d6a308a 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -32,7 +32,6 @@ #include "llbase64.h" #include "llerror.h" -#include "../llmath/llmath.h" #include "llformat.h" #include "llsdserialize.h" #include "stringize.h" @@ -291,10 +290,10 @@ namespace }; LLSD::Boolean ImplReal::asBoolean() const - { return !llisnan(mValue) && mValue != 0.0; } + { return !std::isnan(mValue) && mValue != 0.0; } LLSD::Integer ImplReal::asInteger() const - { return !llisnan(mValue) ? (LLSD::Integer)mValue : 0; } + { return !std::isnan(mValue) ? (LLSD::Integer)mValue : 0; } LLSD::String ImplReal::asString() const { return llformat("%lg", mValue); } diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp index 655869a704..542a3c26e3 100644 --- a/indra/llcommon/llsdjson.cpp +++ b/indra/llcommon/llsdjson.cpp @@ -33,7 +33,6 @@ #include "llsdutil.h" #include "llerror.h" -#include "../llmath/llmath.h" #include diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt index 05b788a433..46503a8a4b 100644 --- a/indra/llcorehttp/CMakeLists.txt +++ b/indra/llcorehttp/CMakeLists.txt @@ -81,6 +81,7 @@ list(APPEND llcorehttp_SOURCE_FILES ${llcorehttp_HEADER_FILES}) add_library (llcorehttp ${llcorehttp_SOURCE_FILES}) target_link_libraries( llcorehttp + llmath llcommon ll::libcurl ll::openssl @@ -92,6 +93,10 @@ target_include_directories( llcorehttp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) # lead to circular dependencies (or in case of cmake, the first project declaring it's dependencies wins) target_include_directories( llcorehttp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../llmessage) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llcorehttp REUSE_FROM llprecompiled) +endif () + # tests set(LLCOREHTTP_TESTS ON CACHE BOOL "Build and run llcorehttp integration tests specifically") @@ -131,7 +136,7 @@ if (LL_TESTS AND LLCOREHTTP_TESTS) ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llcorehttp_peer.py" ) - + # # Example Programs # @@ -151,6 +156,7 @@ if (LL_TESTS AND LLCOREHTTP_TESTS) set_target_properties(http_texture_load PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}" + FOLDER "Tests" ) if (WINDOWS) diff --git a/indra/llcrashlogger/CMakeLists.txt b/indra/llcrashlogger/CMakeLists.txt index 6ac73c0d32..7a1c3eef54 100644 --- a/indra/llcrashlogger/CMakeLists.txt +++ b/indra/llcrashlogger/CMakeLists.txt @@ -21,3 +21,7 @@ list(APPEND llcrashlogger_SOURCE_FILES ${llcrashlogger_HEADER_FILES}) add_library(llcrashlogger ${llcrashlogger_SOURCE_FILES}) target_link_libraries( llcrashlogger llcommon llmessage llcorehttp llxml llfilesystem ) + +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llcrashlogger REUSE_FROM llprecompiled) +endif () diff --git a/indra/llfilesystem/CMakeLists.txt b/indra/llfilesystem/CMakeLists.txt index 9f24f75eab..a552e4bdbc 100644 --- a/indra/llfilesystem/CMakeLists.txt +++ b/indra/llfilesystem/CMakeLists.txt @@ -28,6 +28,12 @@ if (DARWIN) LIST(APPEND llfilesystem_SOURCE_FILES lldir_utils_objc.h) LIST(APPEND llfilesystem_SOURCE_FILES lldir_mac.cpp) LIST(APPEND llfilesystem_HEADER_FILES lldir_mac.h) + + set_source_files_properties( + lldir_utils_objc.mm + PROPERTIES + SKIP_PRECOMPILE_HEADERS TRUE + ) endif (DARWIN) if (LINUX) @@ -52,10 +58,15 @@ list(APPEND llfilesystem_SOURCE_FILES ${llfilesystem_HEADER_FILES}) add_library (llfilesystem ${llfilesystem_SOURCE_FILES}) target_link_libraries(llfilesystem + llmath llcommon ) target_include_directories( llfilesystem INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llfilesystem REUSE_FROM llprecompiled) +endif () + # Add tests if (LL_TESTS) include(LLAddBuildTest) diff --git a/indra/llimage/CMakeLists.txt b/indra/llimage/CMakeLists.txt index cc75c463bc..a81808343f 100644 --- a/indra/llimage/CMakeLists.txt +++ b/indra/llimage/CMakeLists.txt @@ -63,6 +63,10 @@ target_link_libraries(llimage ll::libjpeg ) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llimage REUSE_FROM llprecompiled) +endif () + # Add tests if (LL_TESTS) SET(llimage_TEST_SOURCE_FILES diff --git a/indra/llimagej2coj/CMakeLists.txt b/indra/llimagej2coj/CMakeLists.txt index 93e85668dd..b7ef696b20 100644 --- a/indra/llimagej2coj/CMakeLists.txt +++ b/indra/llimagej2coj/CMakeLists.txt @@ -27,3 +27,6 @@ target_link_libraries( llimagej2coj ll::openjpeg ) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llimagej2coj REUSE_FROM llprecompiled) +endif () diff --git a/indra/llinventory/CMakeLists.txt b/indra/llinventory/CMakeLists.txt index 93a586759f..22966bc55b 100644 --- a/indra/llinventory/CMakeLists.txt +++ b/indra/llinventory/CMakeLists.txt @@ -59,6 +59,10 @@ add_library (llinventory ${llinventory_SOURCE_FILES}) target_link_libraries( llinventory llcommon llmath llmessage llxml ) target_include_directories( llinventory INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llinventory REUSE_FROM llprecompiled) +endif () + #add unit tests if (LL_TESTS) INCLUDE(LLAddBuildTest) diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index bd860adc31..fb57e5db11 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -99,10 +99,14 @@ set(llmath_HEADER_FILES list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES}) -add_library (llmath ${llmath_SOURCE_FILES}) +add_library(llmath ${llmath_SOURCE_FILES}) target_link_libraries(llmath llcommon llmeshoptimizer ll::sse2neon) -target_include_directories( llmath INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(llmath INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llmath REUSE_FROM llprecompiled) +endif () # Add tests if (LL_TESTS) diff --git a/indra/llmeshoptimizer/CMakeLists.txt b/indra/llmeshoptimizer/CMakeLists.txt index dfac44c296..5b1ab9d8e4 100644 --- a/indra/llmeshoptimizer/CMakeLists.txt +++ b/indra/llmeshoptimizer/CMakeLists.txt @@ -30,5 +30,9 @@ target_link_libraries(llmeshoptimizer llmath ll::meshoptimizer) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llmeshoptimizer REUSE_FROM llprecompiled) +endif () + # Add tests diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index b2757a7306..46f28abc9c 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -194,6 +194,10 @@ target_link_libraries( ) target_include_directories( llmessage INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llmessage REUSE_FROM llprecompiled) +endif () + # tests if (LL_TESTS) SET(llmessage_TEST_SOURCE_FILES diff --git a/indra/llphysicsextensionsos/CMakeLists.txt b/indra/llphysicsextensionsos/CMakeLists.txt index c04115ef26..ff1b703dc7 100644 --- a/indra/llphysicsextensionsos/CMakeLists.txt +++ b/indra/llphysicsextensionsos/CMakeLists.txt @@ -43,5 +43,9 @@ if(WINDOWS) target_compile_options(llphysicsextensionsos PRIVATE /bigobj) endif() +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llphysicsextensionsos REUSE_FROM llprecompiled) +endif () + # Add tests diff --git a/indra/llplugin/CMakeLists.txt b/indra/llplugin/CMakeLists.txt index e008a4093e..f67975365a 100644 --- a/indra/llplugin/CMakeLists.txt +++ b/indra/llplugin/CMakeLists.txt @@ -36,5 +36,10 @@ list(APPEND llplugin_SOURCE_FILES ${llplugin_HEADER_FILES}) add_library (llplugin ${llplugin_SOURCE_FILES}) target_include_directories( llplugin INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries( llplugin llcommon llmath llmessage llxml ) + +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llplugin REUSE_FROM llprecompiled) +endif () + add_subdirectory(slplugin) diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 4df3e306cb..f746160ada 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -18,6 +18,12 @@ if (DARWIN) list(APPEND SLPlugin_HEADER_FILES slplugin-objc.h ) + + set_source_files_properties( + slplugin-objc.mm + PROPERTIES + SKIP_PRECOMPILE_HEADERS TRUE + ) endif (DARWIN) if (SLPlugin_HEADER_FILES) @@ -37,6 +43,10 @@ target_link_libraries(SLPlugin ll::pluginlibraries ) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(SLPlugin REUSE_FROM llprecompiled) +endif () + if (WINDOWS) set_target_properties(SLPlugin PROPERTIES diff --git a/indra/llprecompiled/CMakeLists.txt b/indra/llprecompiled/CMakeLists.txt new file mode 100644 index 0000000000..ea230f4a98 --- /dev/null +++ b/indra/llprecompiled/CMakeLists.txt @@ -0,0 +1,53 @@ +# -*- cmake -*- + +project(llprecompiled) + +include(00-Common) +include(APR) +include(bugsplat) +include(Linking) +include(Boost) +include(LLSharedLibs) +include(ZLIBNG) +include(Tracy) +include(EXPAT) +include(SSE2NEON) + +set(llprecompiled_SOURCE_FILES + cmake_dummy.cpp + ) + +add_library (llprecompiled ${llprecompiled_SOURCE_FILES}) + +target_include_directories(llprecompiled PRIVATE + ${CMAKE_SOURCE_DIR}/${LIBS_OPEN_PREFIX}llmath + ) + +target_link_libraries(llprecompiled + llcommon + ll::apr + ll::expat + ll::zlib-ng + ll::boost + ll::oslibraries + ll::tracy + ll::sse2neon + ) + +target_precompile_headers(llprecompiled PRIVATE + [["linden_common.h"]] + [["llwin32headers.h"]] + [["llprofiler.h"]] + [["llmath.h"]] + + + + + + + + + + + + ) diff --git a/indra/llprecompiled/cmake_dummy.cpp b/indra/llprecompiled/cmake_dummy.cpp new file mode 100644 index 0000000000..21a47a9b14 --- /dev/null +++ b/indra/llprecompiled/cmake_dummy.cpp @@ -0,0 +1,24 @@ +/** + * @file cmake_dummy.cpp + * + * $LicenseInfo:firstyear=2008&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ diff --git a/indra/llprimitive/CMakeLists.txt b/indra/llprimitive/CMakeLists.txt index ff0cad58d6..f05be03034 100644 --- a/indra/llprimitive/CMakeLists.txt +++ b/indra/llprimitive/CMakeLists.txt @@ -79,6 +79,10 @@ else() ) endif () +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llprimitive REUSE_FROM llprecompiled) +endif () + #add unit tests if (LL_TESTS) INCLUDE(LLAddBuildTest) diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index d0ae2d6b93..77af0693f3 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -86,6 +86,10 @@ if (BUILD_HEADLESS) ll::freetype OpenGL::GL ) + + if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llrenderheadless REUSE_FROM llprecompiled) + endif() endif (BUILD_HEADLESS) add_library (llrender ${llrender_SOURCE_FILES}) @@ -104,3 +108,6 @@ target_link_libraries(llrender OpenGL::GL ) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llrender REUSE_FROM llprecompiled) +endif () diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 908e94b24c..b543a12281 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -272,6 +272,10 @@ target_link_libraries(llui llcommon ) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llui REUSE_FROM llprecompiled) +endif () + # Add tests if(LL_TESTS) include(LLAddBuildTest) diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index fe45df4021..1f846de35d 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -101,6 +101,13 @@ if (DARWIN) PROPERTIES COMPILE_FLAGS "-fpascal-strings" ) + + set_source_files_properties( + llwindowmacosx-objc.mm + llopenglview-objc.mm + PROPERTIES + SKIP_PRECOMPILE_HEADERS TRUE + ) endif (DARWIN) @@ -170,6 +177,10 @@ if (BUILD_HEADLESS) dl ) target_include_directories(llwindowheadless INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) + + if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llwindowheadless REUSE_FROM llprecompiled) + endif () endif (BUILD_HEADLESS) if (llwindow_HEADER_FILES) @@ -190,6 +201,10 @@ if (USE_SDL_WINDOW) target_compile_definitions( llwindow PUBLIC LL_SDL_WINDOW=1 ) endif() +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llwindow REUSE_FROM llprecompiled) +endif () + if (DARWIN) target_link_libraries(llwindow ${CARBON_LIBRARY}) endif (DARWIN) diff --git a/indra/llxml/CMakeLists.txt b/indra/llxml/CMakeLists.txt index 508c2b919b..bc79e2ef19 100644 --- a/indra/llxml/CMakeLists.txt +++ b/indra/llxml/CMakeLists.txt @@ -34,6 +34,9 @@ target_link_libraries( llxml ) target_include_directories( llxml INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +if (USE_PRECOMPILED_HEADERS) + target_precompile_headers(llxml REUSE_FROM llprecompiled) +endif () # tests -- cgit v1.3 From e803bbc0db695abe73de9797510ba22646528e23 Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 27 Oct 2025 02:55:56 -0400 Subject: Modernize viewer alignment macros to use alignas and fix misaligned class issues reported by ubsan/asan Signed-off-by: Rye --- indra/llappearance/llavatarjoint.h | 6 ++++-- indra/llappearance/llavatarjointmesh.h | 3 ++- indra/llappearance/lldriverparam.h | 2 +- indra/llappearance/llpolymorph.h | 2 +- indra/llappearance/llpolyskeletaldistortion.h | 4 ++-- indra/llappearance/lltexlayerparams.h | 5 ++--- indra/llappearance/llviewervisualparam.h | 5 ++--- indra/llappearanceutility/llbakingavatar.h | 10 +--------- indra/llappearanceutility/llbakingjoint.h | 3 ++- indra/llappearanceutility/llbakingjointmesh.h | 3 ++- indra/llcharacter/lleditingmotion.h | 15 +++++++-------- indra/llcharacter/lljoint.h | 7 +++---- indra/llcharacter/llkeyframestandmotion.h | 5 ++--- indra/llcharacter/llpose.h | 7 +++---- indra/llcharacter/llvisualparam.h | 5 ++--- indra/llcommon/llmemory.h | 16 ---------------- indra/llmath/llcamera.h | 12 ++++++------ indra/llmath/llmatrix3a.cpp | 2 +- indra/llmath/llmatrix3a.h | 5 +++-- indra/llmath/llmatrix4a.h | 5 +++-- indra/llmath/llplane.h | 7 +++---- indra/llmath/llquantize.h | 8 ++++---- indra/llmath/llquaternion2.h | 3 ++- indra/llmath/llquaternion2.inl | 2 +- indra/llmath/llsimdtypes.inl | 4 ++-- indra/llmath/llvector4a.cpp | 4 ++-- indra/llmath/llvector4a.inl | 10 +++++----- indra/llmath/llvector4logical.h | 4 ++-- indra/llmath/llvolumeoctree.h | 6 +++--- indra/llmath/tests/alignment_test.cpp | 5 ++--- indra/llprimitive/llmodel.h | 12 +++++------- indra/newview/lldrawable.h | 5 ++--- indra/newview/lldynamictexture.h | 4 ++-- indra/newview/llspatialpartition.cpp | 9 ++++----- indra/newview/llspatialpartition.h | 13 +++++++------ indra/newview/llviewerjoint.h | 3 ++- indra/newview/llviewerjointattachment.h | 3 ++- indra/newview/llviewerjointmesh.h | 3 ++- indra/newview/llvieweroctree.h | 26 +++++++++++--------------- indra/newview/llvoavatar.cpp | 2 +- indra/newview/llvoavatar.h | 2 +- 41 files changed, 114 insertions(+), 143 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llappearance/llavatarjoint.h b/indra/llappearance/llavatarjoint.h index 13f025fd5f..71fe4b61b6 100644 --- a/indra/llappearance/llavatarjoint.h +++ b/indra/llappearance/llavatarjoint.h @@ -41,9 +41,10 @@ extern const F32 DEFAULT_AVATAR_JOINT_LOD; //----------------------------------------------------------------------------- // class LLViewerJoint //----------------------------------------------------------------------------- -class LLAvatarJoint : +class alignas(16) LLAvatarJoint : public LLJoint { + LL_ALIGN_NEW public: LLAvatarJoint(); LLAvatarJoint(S32 joint_num); @@ -121,8 +122,9 @@ protected: S32 mMeshID; }; -class LLAvatarJointCollisionVolume : public LLAvatarJoint +class alignas(16) LLAvatarJointCollisionVolume : public LLAvatarJoint { + LL_ALIGN_NEW public: LLAvatarJointCollisionVolume(); virtual ~LLAvatarJointCollisionVolume() {}; diff --git a/indra/llappearance/llavatarjointmesh.h b/indra/llappearance/llavatarjointmesh.h index 33f50fce00..153a2b88fe 100644 --- a/indra/llappearance/llavatarjointmesh.h +++ b/indra/llappearance/llavatarjointmesh.h @@ -59,8 +59,9 @@ public: //----------------------------------------------------------------------------- // class LLViewerJointMesh //----------------------------------------------------------------------------- -class LLAvatarJointMesh : public virtual LLAvatarJoint +class alignas(16) LLAvatarJointMesh : public virtual LLAvatarJoint { + LL_ALIGN_NEW protected: LLColor4 mColor; // color value // LLColor4 mSpecular; // specular color (always white for now) diff --git a/indra/llappearance/lldriverparam.h b/indra/llappearance/lldriverparam.h index 59092988dd..df8733dde7 100644 --- a/indra/llappearance/lldriverparam.h +++ b/indra/llappearance/lldriverparam.h @@ -128,7 +128,7 @@ protected: void setDrivenWeight(LLDrivenEntry* driven, F32 driven_weight); - LL_ALIGN_16(LLVector4a mDefaultVec); // temp holder + LLVector4a mDefaultVec; // temp holder entry_list_t mDriven; LLViewerVisualParam* mCurrentDistortionParam{ nullptr }; // Backlink only; don't make this an LLPointer. diff --git a/indra/llappearance/llpolymorph.h b/indra/llappearance/llpolymorph.h index 8c76689f2c..64434bd5d9 100644 --- a/indra/llappearance/llpolymorph.h +++ b/indra/llappearance/llpolymorph.h @@ -71,7 +71,7 @@ public: private: void freeData(); -} LL_ALIGN_POSTFIX(16); +}; //----------------------------------------------------------------------------- diff --git a/indra/llappearance/llpolyskeletaldistortion.h b/indra/llappearance/llpolyskeletaldistortion.h index 9ba4cf66e9..37f35d50ba 100644 --- a/indra/llappearance/llpolyskeletaldistortion.h +++ b/indra/llappearance/llpolyskeletaldistortion.h @@ -111,13 +111,13 @@ public: protected: LLPolySkeletalDistortion(const LLPolySkeletalDistortion& pOther); - LL_ALIGN_16(LLVector4a mDefaultVec); + LLVector4a mDefaultVec; typedef std::map joint_vec_map_t; joint_vec_map_t mJointScales; joint_vec_map_t mJointOffsets; // Backlink only; don't make this an LLPointer. LLAvatarAppearance *mAvatar; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLPOLYSKELETALDISTORTION_H diff --git a/indra/llappearance/lltexlayerparams.h b/indra/llappearance/lltexlayerparams.h index 116eb3bee0..2c243d0e9b 100644 --- a/indra/llappearance/lltexlayerparams.h +++ b/indra/llappearance/lltexlayerparams.h @@ -63,7 +63,6 @@ protected: // LLTexLayerParamAlpha // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LL_ALIGN_PREFIX(16) class alignas(16) LLTexLayerParamAlpha : public LLTexLayerParam { LL_ALIGN_NEW @@ -103,7 +102,7 @@ private: LLPointer mStaticImageRaw; std::atomic mNeedsCreateTexture; bool mStaticImageInvalid; - LL_ALIGN_16(LLVector4a mAvgDistortionVec); + LLVector4a mAvgDistortionVec; F32 mCachedEffectiveWeight; public: @@ -113,7 +112,7 @@ public: typedef std::list< LLTexLayerParamAlpha* > param_alpha_ptr_list_t; static param_alpha_ptr_list_t sInstances; -} LL_ALIGN_POSTFIX(16); +}; class LLTexLayerParamAlphaInfo : public LLViewerVisualParamInfo { friend class LLTexLayerParamAlpha; diff --git a/indra/llappearance/llviewervisualparam.h b/indra/llappearance/llviewervisualparam.h index b79983df8e..37771cc8d3 100644 --- a/indra/llappearance/llviewervisualparam.h +++ b/indra/llappearance/llviewervisualparam.h @@ -65,8 +65,7 @@ protected: // VIRTUAL CLASS // a viewer side interface class for a generalized parametric modification of the avatar mesh //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLViewerVisualParam : public LLVisualParam +class alignas(16) LLViewerVisualParam : public LLVisualParam { public: LLViewerVisualParam(); @@ -107,6 +106,6 @@ public: protected: LLViewerVisualParam(const LLViewerVisualParam& pOther); -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLViewerVisualParam_H diff --git a/indra/llappearanceutility/llbakingavatar.h b/indra/llappearanceutility/llbakingavatar.h index 8261dfc814..b4cf99cbfb 100644 --- a/indra/llappearanceutility/llbakingavatar.h +++ b/indra/llappearanceutility/llbakingavatar.h @@ -38,15 +38,7 @@ class LLBakingAvatar : public LLAvatarAppearance ** INITIALIZATION **/ public: - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } + LL_ALIGN_NEW LLBakingAvatar(LLWearableData* wearable_data, S32 bakeTextureSize = 512); virtual ~LLBakingAvatar(); diff --git a/indra/llappearanceutility/llbakingjoint.h b/indra/llappearanceutility/llbakingjoint.h index 07e15a1d04..10201cc7b8 100644 --- a/indra/llappearanceutility/llbakingjoint.h +++ b/indra/llappearanceutility/llbakingjoint.h @@ -29,8 +29,9 @@ #include "llavatarjoint.h" -class LLBakingJoint : public virtual LLAvatarJoint +class alignas(16) LLBakingJoint : public virtual LLAvatarJoint { + LL_ALIGN_NEW public: LLBakingJoint(); LLBakingJoint(S32 joint_num); diff --git a/indra/llappearanceutility/llbakingjointmesh.h b/indra/llappearanceutility/llbakingjointmesh.h index a66bf3f61b..9c7b276bd8 100644 --- a/indra/llappearanceutility/llbakingjointmesh.h +++ b/indra/llappearanceutility/llbakingjointmesh.h @@ -30,8 +30,9 @@ #include "llavatarjointmesh.h" #include "llbakingjoint.h" -class LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint +class alignas(16) LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint { + LL_ALIGN_NEW public: LLBakingJointMesh(); LLBakingJointMesh(S32 joint_num); diff --git a/indra/llcharacter/lleditingmotion.h b/indra/llcharacter/lleditingmotion.h index f94756d43d..a3c0ee94b7 100644 --- a/indra/llcharacter/lleditingmotion.h +++ b/indra/llcharacter/lleditingmotion.h @@ -42,8 +42,7 @@ //----------------------------------------------------------------------------- // class LLEditingMotion //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLEditingMotion : +class alignas(16) LLEditingMotion : public LLMotion { LL_ALIGN_NEW @@ -110,11 +109,11 @@ public: //------------------------------------------------------------------------- // joint states to be animated //------------------------------------------------------------------------- - LL_ALIGN_16(LLJoint mParentJoint); - LL_ALIGN_16(LLJoint mShoulderJoint); - LL_ALIGN_16(LLJoint mElbowJoint); - LL_ALIGN_16(LLJoint mWristJoint); - LL_ALIGN_16(LLJoint mTarget); + LLJoint mParentJoint; + LLJoint mShoulderJoint; + LLJoint mElbowJoint; + LLJoint mWristJoint; + LLJoint mTarget; LLJointSolverRP3 mIKSolver; LLCharacter *mCharacter; @@ -129,7 +128,7 @@ public: static S32 sHandPose; static S32 sHandPosePriority; LLVector3 mLastSelectPt; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLKEYFRAMEMOTION_H diff --git a/indra/llcharacter/lljoint.h b/indra/llcharacter/lljoint.h index b58dc797f8..481fb0a1bb 100644 --- a/indra/llcharacter/lljoint.h +++ b/indra/llcharacter/lljoint.h @@ -86,8 +86,7 @@ inline bool operator!=(const LLVector3OverrideMap& a, const LLVector3OverrideMap //----------------------------------------------------------------------------- // class LLJoint //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLJoint +class alignas(16) LLJoint { LL_ALIGN_NEW public: @@ -118,7 +117,7 @@ public: }; protected: // explicit transformation members - LL_ALIGN_16(LLMatrix4a mWorldMatrix); + LLMatrix4a mWorldMatrix; LLXformMatrix mXform; std::string mName; @@ -302,6 +301,6 @@ public: // These are used in checks of whether a pos/scale override is considered significant. bool aboveJointPosThreshold(const LLVector3& pos) const; bool aboveJointScaleThreshold(const LLVector3& scale) const; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLJOINT_H diff --git a/indra/llcharacter/llkeyframestandmotion.h b/indra/llcharacter/llkeyframestandmotion.h index df458c7a0c..7d1acb7c5a 100644 --- a/indra/llcharacter/llkeyframestandmotion.h +++ b/indra/llcharacter/llkeyframestandmotion.h @@ -37,8 +37,7 @@ //----------------------------------------------------------------------------- // class LLKeyframeStandMotion //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLKeyframeStandMotion : +class alignas(16) LLKeyframeStandMotion : public LLKeyframeMotion { LL_ALIGN_NEW @@ -112,7 +111,7 @@ public: bool mTrackAnkles; S32 mFrameNum; -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLKEYFRAMESTANDMOTION_H diff --git a/indra/llcharacter/llpose.h b/indra/llcharacter/llpose.h index f2032220e0..fbcd482211 100644 --- a/indra/llcharacter/llpose.h +++ b/indra/llcharacter/llpose.h @@ -80,8 +80,7 @@ public: const S32 JSB_NUM_JOINT_STATES = 6; -LL_ALIGN_PREFIX(16) -class LLJointStateBlender +class alignas(16) LLJointStateBlender { LL_ALIGN_NEW protected: @@ -98,8 +97,8 @@ public: void resetCachedJoint(); public: - LL_ALIGN_16(LLJoint mJointCache); -} LL_ALIGN_POSTFIX(16); + LLJoint mJointCache; +}; class LLMotion; diff --git a/indra/llcharacter/llvisualparam.h b/indra/llcharacter/llvisualparam.h index 3caddb9c62..c99577ed80 100644 --- a/indra/llcharacter/llvisualparam.h +++ b/indra/llcharacter/llvisualparam.h @@ -100,8 +100,7 @@ protected: // An interface class for a generalized parametric modification of the avatar mesh // Contains data that is specific to each Avatar //----------------------------------------------------------------------------- -LL_ALIGN_PREFIX(16) -class LLVisualParam +class alignas(16) LLVisualParam { public: typedef boost::function visual_param_mapper; @@ -180,6 +179,6 @@ protected: S32 mID; // id for storing weight/morphtarget compares compactly LLVisualParamInfo *mInfo; EParamLocation mParamLocation; // where does this visual param live? -} LL_ALIGN_POSTFIX(16); +}; #endif // LL_LLVisualParam_H diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index b47138b0eb..a25387d321 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -92,22 +92,6 @@ template T* LL_NEXT_ALIGNED_ADDRESS_64(T* address) (uintptr_t(address) + 0x3F) & ~0x3F); } -#if LL_LINUX || LL_DARWIN - -#define LL_ALIGN_PREFIX(x) -#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x))) - -#elif LL_WINDOWS - -#define LL_ALIGN_PREFIX(x) __declspec(align(x)) -#define LL_ALIGN_POSTFIX(x) - -#else -#error "LL_ALIGN_PREFIX and LL_ALIGN_POSTFIX undefined" -#endif - -#define LL_ALIGN_16(var) LL_ALIGN_PREFIX(16) var LL_ALIGN_POSTFIX(16) - #define LL_ALIGN_NEW \ public: \ void* operator new(size_t size) \ diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h index 6201761c46..3863588407 100644 --- a/indra/llmath/llcamera.h +++ b/indra/llmath/llcamera.h @@ -60,10 +60,10 @@ constexpr F32 MAX_FIELD_OF_VIEW = 175.f * DEG_TO_RAD; // roll(), pitch(), yaw() // etc... -LL_ALIGN_PREFIX(16) -class LLCamera +class alignas(16) LLCamera : public LLCoordFrame { + LL_ALIGN_NEW public: LLCamera(const LLCamera& rhs) { @@ -120,9 +120,9 @@ public: }; private: - LL_ALIGN_16(LLPlane mAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]); //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP - LL_ALIGN_16(LLPlane mRegionPlanes[AGENT_PLANE_USER_CLIP_NUM]); //frustum planes in a local region space, derived from mAgentPlanes - LL_ALIGN_16(LLPlane mLastAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]); + LLPlane mAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]; //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP + LLPlane mRegionPlanes[AGENT_PLANE_USER_CLIP_NUM]; //frustum planes in a local region space, derived from mAgentPlanes + LLPlane mLastAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]; U8 mPlaneMask[PLANE_MASK_NUM]; // 8 for alignment F32 mView; // angle between top and bottom frustum planes in radians. @@ -218,7 +218,7 @@ protected: void calculateFrustumPlanes(); void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom); void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2); -} LL_ALIGN_POSTFIX(16); +}; #endif diff --git a/indra/llmath/llmatrix3a.cpp b/indra/llmath/llmatrix3a.cpp index c0b00201cf..904c9de2a1 100644 --- a/indra/llmath/llmatrix3a.cpp +++ b/indra/llmath/llmatrix3a.cpp @@ -28,7 +28,7 @@ #include "llmath.h" -static LL_ALIGN_16(const F32 M_IDENT_3A[12]) = +alignas(16) static const F32 M_IDENT_3A[12] = { 1.f, 0.f, 0.f, 0.f, // Column 1 0.f, 1.f, 0.f, 0.f, // Column 2 0.f, 0.f, 1.f, 0.f }; // Column 3 diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h index 9b173c22ed..742a2488fd 100644 --- a/indra/llmath/llmatrix3a.h +++ b/indra/llmath/llmatrix3a.h @@ -40,8 +40,9 @@ // LLMatrix3a is the base class for LLRotation, which should be used instead any time you're dealing with a // rotation matrix. -class LLMatrix3a +class alignas(16) LLMatrix3a { + LL_ALIGN_NEW public: // Utility function for quickly transforming an array of LLVector4a's @@ -111,7 +112,7 @@ public: protected: - LL_ALIGN_16(LLVector4a mColumns[3]); + LLVector4a mColumns[3]; }; diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h index 377203098e..2967949993 100644 --- a/indra/llmath/llmatrix4a.h +++ b/indra/llmath/llmatrix4a.h @@ -31,10 +31,11 @@ #include "m4math.h" #include "m3math.h" -class LLMatrix4a +class alignas(16) LLMatrix4a { + LL_ALIGN_NEW public: - LL_ALIGN_16(LLVector4a mMatrix[4]); + LLVector4a mMatrix[4]; LLMatrix4a() = default; diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h index 832004bb64..822e6a7b6f 100644 --- a/indra/llmath/llplane.h +++ b/indra/llmath/llplane.h @@ -36,10 +36,9 @@ // The plane normal = [A, B, C] // The closest approach = D / sqrt(A*A + B*B + C*C) - -LL_ALIGN_PREFIX(16) -class LLPlane +class alignas(16) LLPlane { + LL_ALIGN_NEW public: // Constructors @@ -102,7 +101,7 @@ public: private: LLVector4a mV; -} LL_ALIGN_POSTFIX(16); +}; static_assert(std::is_trivial::value, "LLPlane must be a trivial type"); diff --git a/indra/llmath/llquantize.h b/indra/llmath/llquantize.h index e8d880122e..2a53fdbf84 100644 --- a/indra/llmath/llquantize.h +++ b/indra/llmath/llquantize.h @@ -29,16 +29,16 @@ #define LL_LLQUANTIZE_H const U16 U16MAX = 65535; -LL_ALIGN_16( const F32 F_U16MAX_4A[4] ) = { 65535.f, 65535.f, 65535.f, 65535.f }; +alignas(16) const F32 F_U16MAX_4A[4] = { 65535.f, 65535.f, 65535.f, 65535.f }; const F32 OOU16MAX = 1.f/(F32)(U16MAX); -LL_ALIGN_16( const F32 F_OOU16MAX_4A[4] ) = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX }; +alignas(16) const F32 F_OOU16MAX_4A[4] = { OOU16MAX, OOU16MAX, OOU16MAX, OOU16MAX }; const U8 U8MAX = 255; -LL_ALIGN_16( const F32 F_U8MAX_4A[4] ) = { 255.f, 255.f, 255.f, 255.f }; +alignas(16) const F32 F_U8MAX_4A[4] = { 255.f, 255.f, 255.f, 255.f }; const F32 OOU8MAX = 1.f/(F32)(U8MAX); -LL_ALIGN_16( const F32 F_OOU8MAX_4A[4] ) = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX }; +alignas(16) const F32 F_OOU8MAX_4A[4] = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX }; const U8 FIRSTVALIDCHAR = 54; const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null diff --git a/indra/llmath/llquaternion2.h b/indra/llmath/llquaternion2.h index c9dcc4573f..d73e1a0ca2 100644 --- a/indra/llmath/llquaternion2.h +++ b/indra/llmath/llquaternion2.h @@ -40,8 +40,9 @@ ///////////////////////////// #include "llquaternion.h" -class LLQuaternion2 +class alignas(16) LLQuaternion2 { + LL_ALIGN_NEW public: ////////////////////////// diff --git a/indra/llmath/llquaternion2.inl b/indra/llmath/llquaternion2.inl index ce5ed73926..2ebc8e0bfb 100644 --- a/indra/llmath/llquaternion2.inl +++ b/indra/llmath/llquaternion2.inl @@ -57,7 +57,7 @@ inline LLVector4a& LLQuaternion2::getVector4aRw() // Set this quaternion to the conjugate of src inline void LLQuaternion2::setConjugate(const LLQuaternion2& src) { - static LL_ALIGN_16( const U32 F_QUAT_INV_MASK_4A[4] ) = { 0x80000000, 0x80000000, 0x80000000, 0x00000000 }; + alignas(16) static const U32 F_QUAT_INV_MASK_4A[4] = { 0x80000000, 0x80000000, 0x80000000, 0x00000000 }; mQ = _mm_xor_ps(src.mQ, *reinterpret_cast(&F_QUAT_INV_MASK_4A)); } diff --git a/indra/llmath/llsimdtypes.inl b/indra/llmath/llsimdtypes.inl index 125f4b9df5..20ea7640b6 100644 --- a/indra/llmath/llsimdtypes.inl +++ b/indra/llmath/llsimdtypes.inl @@ -61,7 +61,7 @@ inline LLSimdScalar operator/(const LLSimdScalar& a, const LLSimdScalar& b) inline LLSimdScalar operator-(const LLSimdScalar& a) { - static LL_ALIGN_16(const U32 signMask[4]) = {0x80000000, 0x80000000, 0x80000000, 0x80000000 }; + alignas(16) static const U32 signMask[4] = {0x80000000, 0x80000000, 0x80000000, 0x80000000 }; ll_assert_aligned(signMask,16); return _mm_xor_ps(*reinterpret_cast(signMask), a); } @@ -146,7 +146,7 @@ inline LLSimdScalar& LLSimdScalar::operator/=(const LLSimdScalar& rhs) inline LLSimdScalar LLSimdScalar::getAbs() const { - static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; + alignas(16) static const U32 F_ABS_MASK_4A[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; ll_assert_aligned(F_ABS_MASK_4A,16); return _mm_and_ps( mQ, *reinterpret_cast(F_ABS_MASK_4A)); } diff --git a/indra/llmath/llvector4a.cpp b/indra/llmath/llvector4a.cpp index b81d50f0f9..6bdc97e420 100644 --- a/indra/llmath/llvector4a.cpp +++ b/indra/llmath/llvector4a.cpp @@ -101,7 +101,7 @@ void LLVector4a::quantize8( const LLVector4a& low, const LLVector4a& high ) // 8-bit quantization means we can do with just 12 bits of reciprocal accuracy const LLVector4a oneOverDelta = _mm_rcp_ps(delta.mQ); // { -// static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f }; +// alignas(16) static const F32 F_TWO_4A[4] = { 2.f, 2.f, 2.f, 2.f }; // LLVector4a two; two.load4a( F_TWO_4A ); // // // Here we use _mm_rcp_ps plus one round of newton-raphson @@ -146,7 +146,7 @@ void LLVector4a::quantize16( const LLVector4a& low, const LLVector4a& high ) // 16-bit quantization means we need a round of Newton-Raphson LLVector4a oneOverDelta; { - static LL_ALIGN_16( const F32 F_TWO_4A[4] ) = { 2.f, 2.f, 2.f, 2.f }; + alignas(16) static const F32 F_TWO_4A[4] = { 2.f, 2.f, 2.f, 2.f }; ll_assert_aligned(F_TWO_4A,16); LLVector4a two; two.load4a( F_TWO_4A ); diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 443a46c317..b6e2a4fce5 100644 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -196,7 +196,7 @@ inline void LLVector4a::setDiv(const LLVector4a& a, const LLVector4a& b) // Set this to the element-wise absolute value of src inline void LLVector4a::setAbs(const LLVector4a& src) { - static const LL_ALIGN_16(U32 F_ABS_MASK_4A[4]) = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; + alignas(16) static const U32 F_ABS_MASK_4A[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF }; mQ = _mm_and_ps(src.mQ, *reinterpret_cast(F_ABS_MASK_4A)); } @@ -448,7 +448,7 @@ inline void LLVector4a::normalize3fast_checked(LLVector4a* d) // Return true if this vector is normalized with respect to x,y,z up to tolerance inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const { - static LL_ALIGN_16(const U32 ones[4]) = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; + alignas(16) static const U32 ones[4] = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; LLSimdScalar tol = _mm_load_ss( &tolerance ); tol = _mm_mul_ss( tol, tol ); LLVector4a lenSquared; lenSquared.setAllDot3( *this, *this ); @@ -460,7 +460,7 @@ inline LLBool32 LLVector4a::isNormalized3( F32 tolerance ) const // Return true if this vector is normalized with respect to all components up to tolerance inline LLBool32 LLVector4a::isNormalized4( F32 tolerance ) const { - static LL_ALIGN_16(const U32 ones[4]) = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; + alignas(16) static const U32 ones[4] = { 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000 }; LLSimdScalar tol = _mm_load_ss( &tolerance ); tol = _mm_mul_ss( tol, tol ); LLVector4a lenSquared; lenSquared.setAllDot4( *this, *this ); @@ -507,7 +507,7 @@ inline void LLVector4a::setLerp(const LLVector4a& lhs, const LLVector4a& rhs, F3 inline LLBool32 LLVector4a::isFinite3() const { - static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; + alignas(16) static const U32 nanOrInfMask[4] = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; ll_assert_aligned(nanOrInfMask,16); const __m128i nanOrInfMaskV = *reinterpret_cast (nanOrInfMask); const __m128i maskResult = _mm_and_si128( _mm_castps_si128(mQ), nanOrInfMaskV ); @@ -517,7 +517,7 @@ inline LLBool32 LLVector4a::isFinite3() const inline LLBool32 LLVector4a::isFinite4() const { - static LL_ALIGN_16(const U32 nanOrInfMask[4]) = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; + alignas(16) static const U32 nanOrInfMask[4] = { 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000 }; const __m128i nanOrInfMaskV = *reinterpret_cast (nanOrInfMask); const __m128i maskResult = _mm_and_si128( _mm_castps_si128(mQ), nanOrInfMaskV ); const LLVector4Logical equalityCheck = _mm_castsi128_ps(_mm_cmpeq_epi32( maskResult, nanOrInfMaskV )); diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h index 77cb5862e5..411971c42d 100644 --- a/indra/llmath/llvector4logical.h +++ b/indra/llmath/llvector4logical.h @@ -39,7 +39,7 @@ // contact someone with SSE experience (Falcon, Richard, Davep, e.g.) //////////////////////////// -static LL_ALIGN_16(const U32 S_V4LOGICAL_MASK_TABLE[4*4]) = +alignas(16) static const U32 S_V4LOGICAL_MASK_TABLE[4*4] = { 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0x00000000, 0x00000000, @@ -77,7 +77,7 @@ public: // Invert this mask inline LLVector4Logical& invert() { - static const LL_ALIGN_16(U32 allOnes[4]) = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; + alignas(16) static const U32 allOnes[4] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; ll_assert_aligned(allOnes,16); mQ = _mm_andnot_ps( mQ, *(LLQuad*)(allOnes) ); return *this; diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 1d74644715..4200e0d5a1 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -53,7 +53,7 @@ public: } - LL_ALIGN_16(LLVector4a mPositionGroup); + LLVector4a mPositionGroup; const LLVector4a* mV[3]; U32 mIndex[3]; @@ -99,8 +99,8 @@ public: public: - LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects) - LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children + LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects) + LLVector4a mExtents[2]; // extents (min, max) of this node and all its children }; class LLOctreeTriangleRayIntersect : public LLOctreeTraveler diff --git a/indra/llmath/tests/alignment_test.cpp b/indra/llmath/tests/alignment_test.cpp index eb6fa4a3b8..f41ebe82aa 100644 --- a/indra/llmath/tests/alignment_test.cpp +++ b/indra/llmath/tests/alignment_test.cpp @@ -46,8 +46,7 @@ typedef test_group alignment_test_t; typedef alignment_test_t::object alignment_test_object_t; tut::alignment_test_t tut_alignment_test("LLAlignment"); -LL_ALIGN_PREFIX(16) -class MyVector4a +class alignas(16) MyVector4a { public: void* operator new(size_t size) @@ -71,7 +70,7 @@ public: } LLQuad mQ; -} LL_ALIGN_POSTFIX(16); +}; // Verify that aligned allocators perform as advertised. diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index ac88af18f0..26448069c6 100644 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -40,8 +40,7 @@ class domMesh; #define MAX_MODEL_FACES 8 -LL_ALIGN_PREFIX(16) -class LLMeshSkinInfo : public LLRefCount +class alignas(16) LLMeshSkinInfo : public LLRefCount { LL_ALIGN_NEW public: @@ -65,17 +64,16 @@ public: // cached multiply of mBindShapeMatrix and mInvBindMatrix matrix_list_t mBindPoseMatrix; - LL_ALIGN_16(LLMatrix4a mBindShapeMatrix); + LLMatrix4a mBindShapeMatrix; float mPelvisOffset; bool mLockScaleIfJointPosition; bool mInvalidJointsScrubbed; bool mJointNumsInitialized; U64 mHash = 0; -} LL_ALIGN_POSTFIX(16); +}; -LL_ALIGN_PREFIX(16) -class LLModel : public LLVolume +class alignas(16) LLModel : public LLVolume { LL_ALIGN_NEW public: @@ -323,7 +321,7 @@ public: // A model/object can only have 8 faces, spillover faces will // be moved to new model/object and assigned a submodel id. int mSubmodelID; -} LL_ALIGN_POSTFIX(16); +}; typedef std::vector > model_list; typedef std::queue > model_queue; diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index a7ac9da618..d05cd0ee2b 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -59,8 +59,7 @@ class LLViewerTexture; const U32 SILHOUETTE_HIGHLIGHT = 0; // All data for new renderer goes into this class. -LL_ALIGN_PREFIX(16) -class LLDrawable +class alignas(16) LLDrawable : public LLViewerOctreeEntryData { LL_ALIGN_NEW; @@ -313,7 +312,7 @@ private: static U32 sNumZombieDrawables; static std::vector > sDeadList; -} LL_ALIGN_POSTFIX(16); +}; inline LLFace* LLDrawable::getFace(const S32 i) const diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h index 375828fefa..cc5e39c5fb 100644 --- a/indra/newview/lldynamictexture.h +++ b/indra/newview/lldynamictexture.h @@ -33,7 +33,7 @@ #include "llviewertexture.h" #include "llcamera.h" -class LLViewerDynamicTexture : public LLViewerTexture +class alignas(16) LLViewerDynamicTexture : public LLViewerTexture { LL_ALIGN_NEW public: @@ -90,7 +90,7 @@ protected: protected: bool mClamp; LLCoordGL mOrigin; - LL_ALIGN_16(LLCamera mCamera); + LLCamera mCamera; LLRenderTarget* mBoundTarget; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f3cfbd9565..4ba47aa4da 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3625,12 +3625,11 @@ bool LLSpatialPartition::isVisible(const LLVector3& v) return true; } -LL_ALIGN_PREFIX(16) -class LLOctreeIntersect : public LLOctreeTraveler> +class alignas(16) LLOctreeIntersect : public LLOctreeTraveler> { public: - LL_ALIGN_16(LLVector4a mStart); - LL_ALIGN_16(LLVector4a mEnd); + LLVector4a mStart; + LLVector4a mEnd; S32 *mFaceHit; LLVector4a *mIntersection; @@ -3780,7 +3779,7 @@ public: return false; } -} LL_ALIGN_POSTFIX(16); +}; LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 3aaa3d60e8..4ca1ef7c7a 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -64,7 +64,7 @@ void pushVerts(LLFace* face); Make every effort to keep size minimal. Member ordering is important for cache coherency */ -class LLDrawInfo final : public LLRefCount +class alignas(16) LLDrawInfo final : public LLRefCount { LL_ALIGN_NEW; protected: @@ -198,12 +198,13 @@ public: }; }; -LL_ALIGN_PREFIX(16) -class LLSpatialGroup : public LLOcclusionCullingGroup +class alignas(16) LLSpatialGroup : public LLOcclusionCullingGroup { using super = LLOcclusionCullingGroup; friend class LLSpatialPartition; friend class LLOctreeStateCheck; + + LL_ALIGN_NEW public: LLSpatialGroup(const LLSpatialGroup& rhs) : LLOcclusionCullingGroup(rhs) @@ -338,8 +339,8 @@ public: virtual void rebound(); public: - LL_ALIGN_16(LLVector4a mViewAngle); - LL_ALIGN_16(LLVector4a mLastUpdateViewAngle); + LLVector4a mViewAngle; + LLVector4a mLastUpdateViewAngle; protected: virtual ~LLSpatialGroup(); @@ -369,7 +370,7 @@ public: U32 mRenderOrder = 0; // Reflection Probe associated with this node (if any) LLPointer mReflectionProbe = nullptr; -} LL_ALIGN_POSTFIX(16); +}; class LLGeometryManager { diff --git a/indra/newview/llviewerjoint.h b/indra/newview/llviewerjoint.h index 7f52ca9623..57959ec2fc 100644 --- a/indra/newview/llviewerjoint.h +++ b/indra/newview/llviewerjoint.h @@ -39,9 +39,10 @@ class LLViewerJointMesh; //----------------------------------------------------------------------------- // class LLViewerJoint //----------------------------------------------------------------------------- -class LLViewerJoint : +class alignas(16) LLViewerJoint : public virtual LLAvatarJoint { + LL_ALIGN_NEW public: LLViewerJoint(); LLViewerJoint(S32 joint_num); diff --git a/indra/newview/llviewerjointattachment.h b/indra/newview/llviewerjointattachment.h index fe66949f73..12075177b3 100644 --- a/indra/newview/llviewerjointattachment.h +++ b/indra/newview/llviewerjointattachment.h @@ -40,9 +40,10 @@ class LLViewerObject; //----------------------------------------------------------------------------- // class LLViewerJointAttachment //----------------------------------------------------------------------------- -class LLViewerJointAttachment : +class alignas(16) LLViewerJointAttachment : public LLViewerJoint { + LL_ALIGN_NEW public: LLViewerJointAttachment(); virtual ~LLViewerJointAttachment(); diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h index cfe8ecdb67..a3afd84d06 100644 --- a/indra/newview/llviewerjointmesh.h +++ b/indra/newview/llviewerjointmesh.h @@ -41,8 +41,9 @@ class LLViewerTexLayerSet; //----------------------------------------------------------------------------- // class LLViewerJointMesh //----------------------------------------------------------------------------- -class LLViewerJointMesh : public LLAvatarJointMesh, public LLViewerJoint +class alignas(16) LLViewerJointMesh : public LLAvatarJointMesh, public LLViewerJoint { + LL_ALIGN_NEW public: // Constructor LLViewerJointMesh(); diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index 60e17a6f58..83b8aa8d03 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -70,8 +70,7 @@ S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVect S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared); //defines data needed for octree of an entry -//LL_ALIGN_PREFIX(16) -class LLViewerOctreeEntry : public LLRefCount +class alignas(16) LLViewerOctreeEntry : public LLRefCount { LL_ALIGN_NEW friend class LLViewerOctreeEntryData; @@ -115,16 +114,15 @@ private: LLViewerOctreeGroup* mGroup; //aligned members - LL_ALIGN_16(LLVector4a mExtents[2]); - LL_ALIGN_16(LLVector4a mPositionGroup); + LLVector4a mExtents[2]; + LLVector4a mPositionGroup; F32 mBinRadius; mutable S32 mBinIndex; mutable U32 mVisible; -} ;//LL_ALIGN_POSTFIX(16); +}; //defines an abstract class for entry data -//LL_ALIGN_PREFIX(16) class LLViewerOctreeEntryData : public LLRefCount { protected: @@ -173,11 +171,10 @@ protected: LLPointer mEntry; LLViewerOctreeEntry::eEntryDataType_t mDataType; static U32 sCurVisible; // Counter for what value of mVisible means currently visible -};//LL_ALIGN_POSTFIX(16); +}; //defines an octree group for an octree node, which contains multiple entries. -//LL_ALIGN_PREFIX(16) class LLViewerOctreeGroup : public OctreeListener { @@ -259,18 +256,17 @@ protected: U32 mState; OctreeNode* mOctreeNode; - LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects) - LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node - LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children - LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node + LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects) + LLVector4a mObjectBounds[2]; // bounding box (center, size) of objects in this node + LLVector4a mExtents[2]; // extents (min, max) of this node and all its children + LLVector4a mObjectExtents[2]; // extents (min, max) of objects in this node S32 mAnyVisible; //latest visible to any camera S32 mVisible[LLViewerCamera::NUM_CAMERAS]; -};//LL_ALIGN_POSTFIX(16); +}; //octree group which has capability to support occlusion culling -//LL_ALIGN_PREFIX(16) class LLOcclusionCullingGroup : public LLViewerOctreeGroup { public: @@ -340,7 +336,7 @@ protected: public: static std::set sPendingQueries; -};//LL_ALIGN_POSTFIX(16); +}; class LLViewerOctreePartition { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index c6a7a59034..25b7c58733 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3074,7 +3074,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update) if (isImpostor() && !mNeedsImpostorUpdate) { - LL_ALIGN_16(LLVector4a ext[2]); + LLVector4a ext[2]; F32 distance; LLVector3 angle; diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 5c062870a0..a1675e8a02 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -264,7 +264,7 @@ public: private: //aligned members - LL_ALIGN_16(LLVector4a mImpostorExtents[2]); + LLVector4a mImpostorExtents[2]; //-------------------------------------------------------------------- // Updates -- cgit v1.3 From 2d40a1cfa9930f96570cccf415f6038d6dcc657c Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 15 Dec 2025 17:41:05 -0500 Subject: Clean up dead legacy headers and compiler work arounds Clean up dead macos files Clean up dead windows build files Signed-off-by: Rye --- indra/llcommon/CMakeLists.txt | 3 - indra/llcommon/ctype_workaround.h | 54 ------- indra/llcommon/fix_macros.h | 21 --- indra/llcommon/llapr.h | 2 +- indra/llcommon/llcond.h | 2 +- indra/llcommon/llcoros.h | 2 +- indra/llcommon/llfixedbuffer.h | 2 +- indra/llcommon/llinstancetracker.h | 2 +- indra/llcommon/llmutex.h | 2 +- indra/llcommon/llsingleton.h | 2 +- indra/llcommon/llthreadsafequeue.h | 2 +- indra/llcommon/lockstatic.h | 2 +- indra/llcommon/mutex.h | 22 --- indra/llcommon/timer.h | 26 ---- indra/llcorehttp/_refcounted.h | 1 - indra/llfilesystem/lldiriterator.cpp | 1 - indra/llmath/CMakeLists.txt | 2 - indra/llmath/camera.h | 27 ---- indra/llmath/coordframe.h | 27 ---- indra/llwindow/llwindowmacosx.h | 5 - indra/newview/CMakeLists.txt | 2 - indra/newview/Info-SecondLifeVorbis.plist | 28 ---- indra/newview/VertexCache.h | 105 -------------- indra/newview/VorbisFramework.h | 80 ----------- indra/newview/build_win32_appConfig.py | 68 --------- indra/newview/lllocalbitmaps.cpp | 2 - indra/newview/lllocalgltfmaterials.cpp | 2 - indra/newview/macutil_Prefix.h | 38 ----- indra/newview/macview_Prefix.h | 229 ------------------------------ indra/test/test.cpp | 11 -- 30 files changed, 9 insertions(+), 763 deletions(-) delete mode 100644 indra/llcommon/ctype_workaround.h delete mode 100644 indra/llcommon/fix_macros.h delete mode 100644 indra/llcommon/mutex.h delete mode 100644 indra/llcommon/timer.h delete mode 100644 indra/llmath/camera.h delete mode 100644 indra/llmath/coordframe.h delete mode 100644 indra/newview/Info-SecondLifeVorbis.plist delete mode 100644 indra/newview/VertexCache.h delete mode 100644 indra/newview/VorbisFramework.h delete mode 100755 indra/newview/build_win32_appConfig.py delete mode 100644 indra/newview/macutil_Prefix.h delete mode 100644 indra/newview/macview_Prefix.h (limited to 'indra/llmath') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 7311c6faf6..980b8ca05c 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -117,8 +117,6 @@ set(llcommon_HEADER_FILES chrono.h classic_callback.h commoncontrol.h - ctype_workaround.h - fix_macros.h fsyspath.h function_types.h indra_constants.h @@ -249,7 +247,6 @@ set(llcommon_HEADER_FILES threadpool.h threadpool_fwd.h threadsafeschedule.h - timer.h tuple.h u64.h workqueue.h diff --git a/indra/llcommon/ctype_workaround.h b/indra/llcommon/ctype_workaround.h deleted file mode 100644 index 89a47fe3db..0000000000 --- a/indra/llcommon/ctype_workaround.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file ctype_workaround.h - * @brief The workaround is to create some legacy symbols that point - * to the correct symbols, which avoids link errors. - * - * $LicenseInfo:firstyear=2006&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef _CTYPE_WORKAROUND_H_ -#define _CTYPE_WORKAROUND_H_ - -/** - * the CTYPE_WORKAROUND is needed for linux dev stations that don't - * have the broken libc6 packages needed by our out-of-date static - * libs (such as libcrypto and libcurl). - * - * -- Leviathan 20060113 -*/ - -#include - -__const unsigned short int *__ctype_b; -__const __int32_t *__ctype_tolower; -__const __int32_t *__ctype_toupper; - -// call this function at the beginning of main() -void ctype_workaround() -{ - __ctype_b = *(__ctype_b_loc()); - __ctype_toupper = *(__ctype_toupper_loc()); - __ctype_tolower = *(__ctype_tolower_loc()); -} - -#endif - diff --git a/indra/llcommon/fix_macros.h b/indra/llcommon/fix_macros.h deleted file mode 100644 index ed6c26a371..0000000000 --- a/indra/llcommon/fix_macros.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @file fix_macros.h - * @author Nat Goodspeed - * @date 2012-11-16 - * @brief The Mac system headers seem to #define macros with obnoxiously - * generic names, preventing any library from using those names. We've - * had to fix these in so many places that it's worth making a header - * file to handle it. - * - * $LicenseInfo:firstyear=2012&license=viewerlgpl$ - * Copyright (c) 2012, Linden Research, Inc. - * $/LicenseInfo$ - */ - -// DON'T use an #include guard: every time we encounter this header, #undef -// these macros all over again. - -// who injects MACROS with such generic names?! Grr. -#ifdef check -#undef check -#endif diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 11e474b5dd..0e1e4277e7 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -40,7 +40,7 @@ #include "llstring.h" -#include "mutex.h" +#include struct apr_dso_handle_t; /** diff --git a/indra/llcommon/llcond.h b/indra/llcommon/llcond.h index 2df1719941..b72ea33dea 100644 --- a/indra/llcommon/llcond.h +++ b/indra/llcommon/llcond.h @@ -17,7 +17,7 @@ #include "llunits.h" #include "llcoros.h" #include LLCOROS_MUTEX_HEADER -#include "mutex.h" +#include #include /** diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 9df52b6ed5..602c65b9ba 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -34,10 +34,10 @@ #include #include #include -#include "mutex.h" #include "llsingleton.h" #include "llinstancetracker.h" #include +#include #include #include #include diff --git a/indra/llcommon/llfixedbuffer.h b/indra/llcommon/llfixedbuffer.h index 1234d2014f..d2cd660c18 100644 --- a/indra/llcommon/llfixedbuffer.h +++ b/indra/llcommon/llfixedbuffer.h @@ -27,7 +27,7 @@ #ifndef LL_LLFIXEDBUFFER_H #define LL_LLFIXEDBUFFER_H -#include "timer.h" +#include "lltimer.h" #include #include #include "llstring.h" diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index 5a7f27e688..734365767d 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -37,7 +37,7 @@ #include #include -#include "mutex.h" +#include #include #include diff --git a/indra/llcommon/llmutex.h b/indra/llcommon/llmutex.h index f3615a1270..bc3d8fed06 100644 --- a/indra/llcommon/llmutex.h +++ b/indra/llcommon/llmutex.h @@ -30,7 +30,7 @@ #include "stdtypes.h" #include "llthread.h" -#include "mutex.h" +#include #include #include #include diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 3fba8602ee..81e69ab63c 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -30,7 +30,7 @@ #include #include #include -#include "mutex.h" +#include #include "lockstatic.h" #include "llthread.h" // on_main_thread() #include "llmainthreadtask.h" diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 1a1d06a6fd..2a18b4a438 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -32,7 +32,7 @@ #include #include LLCOROS_CONDVAR_HEADER #include "llexception.h" -#include "mutex.h" +#include #include #include #include diff --git a/indra/llcommon/lockstatic.h b/indra/llcommon/lockstatic.h index 7cc9b7eec0..db4c7af0ec 100644 --- a/indra/llcommon/lockstatic.h +++ b/indra/llcommon/lockstatic.h @@ -13,7 +13,7 @@ #if ! defined(LL_LOCKSTATIC_H) #define LL_LOCKSTATIC_H -#include "mutex.h" // std::unique_lock +#include // std::unique_lock namespace llthread { diff --git a/indra/llcommon/mutex.h b/indra/llcommon/mutex.h deleted file mode 100644 index 82e46315e2..0000000000 --- a/indra/llcommon/mutex.h +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @file mutex.h - * @author Nat Goodspeed - * @date 2019-12-03 - * @brief Wrap in odious boilerplate - * - * $LicenseInfo:firstyear=2019&license=viewerlgpl$ - * Copyright (c) 2019, Linden Research, Inc. - * $/LicenseInfo$ - */ - -#if LL_WINDOWS -#pragma warning (push) -#pragma warning (disable:4265) -#endif -// warning C4265: 'std::_Pad' : class has virtual functions, but destructor is not virtual - -#include - -#if LL_WINDOWS -#pragma warning (pop) -#endif diff --git a/indra/llcommon/timer.h b/indra/llcommon/timer.h deleted file mode 100644 index aaa0cf0775..0000000000 --- a/indra/llcommon/timer.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file timer.h - * @brief Legacy wrapper header. - * - * $LicenseInfo:firstyear=2000&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -#include "lltimer.h" diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h index 1a01d66d14..bc90f8274d 100644 --- a/indra/llcorehttp/_refcounted.h +++ b/indra/llcorehttp/_refcounted.h @@ -30,7 +30,6 @@ #include "linden_common.h" -#include "fix_macros.h" #include #include "llatomic.h" diff --git a/indra/llfilesystem/lldiriterator.cpp b/indra/llfilesystem/lldiriterator.cpp index b736a577bd..57d4912c94 100644 --- a/indra/llfilesystem/lldiriterator.cpp +++ b/indra/llfilesystem/lldiriterator.cpp @@ -28,7 +28,6 @@ #include "lldiriterator.h" -#include "fix_macros.h" #include "llregex.h" #include diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index fb57e5db11..a4e4d0a50b 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -46,8 +46,6 @@ set(llmath_SOURCE_FILES set(llmath_HEADER_FILES CMakeLists.txt - camera.h - coordframe.h llbbox.h llbboxlocal.h llcalc.h diff --git a/indra/llmath/camera.h b/indra/llmath/camera.h deleted file mode 100644 index 14a08c5985..0000000000 --- a/indra/llmath/camera.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @file camera.h - * @brief Legacy wrapper header. - * - * $LicenseInfo:firstyear=2000&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llcamera.h" diff --git a/indra/llmath/coordframe.h b/indra/llmath/coordframe.h deleted file mode 100644 index e7395b1212..0000000000 --- a/indra/llmath/coordframe.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @file coordframe.h - * @brief Legacy wrapper header. - * - * $LicenseInfo:firstyear=2000&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llcoordframe.h" diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index d703a84d02..dc8b7504c9 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -36,11 +36,6 @@ #include #include -// AssertMacros.h does bad things. -#include "fix_macros.h" -#undef verify -#undef require - class LLWindowMacOSX : public LLWindow { public: diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 09fb54faf4..c2b1473e8f 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1430,8 +1430,6 @@ set(viewer_HEADER_FILES noise.h pipeline.h roles_constants.h - VertexCache.h - VorbisFramework.h ) source_group("CMake Rules" FILES ViewerInstall.cmake) diff --git a/indra/newview/Info-SecondLifeVorbis.plist b/indra/newview/Info-SecondLifeVorbis.plist deleted file mode 100644 index 9cb367eec1..0000000000 --- a/indra/newview/Info-SecondLifeVorbis.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - SecondLifeVorbis - CFBundleGetInfoString - - CFBundleIconFile - - CFBundleIdentifier - com.secondlife.indra.vorbis - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - SecondLifeVorbis - CFBundlePackageType - FMWK - CFBundleShortVersionString - - CFBundleSignature - ???? - CFBundleVersion - 0.0.1d1 - - diff --git a/indra/newview/VertexCache.h b/indra/newview/VertexCache.h deleted file mode 100644 index edb231feb1..0000000000 --- a/indra/newview/VertexCache.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file VertexCache.h - * @brief VertexCache class definition - * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - - -#ifndef VERTEX_CACHE_H - -#define VERTEX_CACHE_H - -class VertexCache -{ - -public: - - VertexCache(int size) - { - numEntries = size; - - entries = new int[numEntries]; - - for(int i = 0; i < numEntries; i++) - entries[i] = -1; - } - - VertexCache() { VertexCache(16); } - ~VertexCache() { delete[] entries; entries = 0; } - - bool InCache(int entry) - { - bool returnVal = false; - for(int i = 0; i < numEntries; i++) - { - if(entries[i] == entry) - { - returnVal = true; - break; - } - } - - return returnVal; - } - - int AddEntry(int entry) - { - int removed; - - removed = entries[numEntries - 1]; - - //push everything right one - for(int i = numEntries - 2; i >= 0; i--) - { - entries[i + 1] = entries[i]; - } - - entries[0] = entry; - - return removed; - } - - void Clear() - { - memset(entries, -1, sizeof(int) * numEntries); - } - - void Copy(VertexCache* inVcache) - { - for(int i = 0; i < numEntries; i++) - { - inVcache->Set(i, entries[i]); - } - } - - int At(int index) { return entries[index]; } - void Set(int index, int value) { entries[index] = value; } - -private: - - int *entries; - int numEntries; - -}; - -#endif diff --git a/indra/newview/VorbisFramework.h b/indra/newview/VorbisFramework.h deleted file mode 100644 index 7ee9a8c411..0000000000 --- a/indra/newview/VorbisFramework.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file VorbisFramework.h - * @author Dave Camp - * @date Fri Oct 10 2003 - * @brief For the Macview project - * - * $LicenseInfo:firstyear=2003&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "ogg/ogg.h" -#include "vorbis/codec.h" -#include "vorbis/vorbisenc.h" - -extern int mac_vorbis_analysis(vorbis_block *vb,ogg_packet *op); - -extern int mac_vorbis_analysis_headerout(vorbis_dsp_state *v, - vorbis_comment *vc, - ogg_packet *op, - ogg_packet *op_comm, - ogg_packet *op_code); - -extern int mac_vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); - -extern int mac_vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); - -extern int mac_vorbis_encode_setup_init(vorbis_info *vi); - -extern int mac_vorbis_encode_setup_managed(vorbis_info *vi, - long channels, - long rate, - - long max_bitrate, - long nominal_bitrate, - long min_bitrate); - -extern void mac_vorbis_info_init(vorbis_info *vi); -extern void mac_vorbis_info_clear(vorbis_info *vi); -extern void mac_vorbis_comment_init(vorbis_comment *vc); -extern void mac_vorbis_comment_clear(vorbis_comment *vc); -extern int mac_vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); -extern int mac_vorbis_block_clear(vorbis_block *vb); -extern void mac_vorbis_dsp_clear(vorbis_dsp_state *v); -extern float **mac_vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); -extern int mac_vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); -extern int mac_vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); - -extern int mac_ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); -extern int mac_ogg_stream_init(ogg_stream_state *os,int serialno); -extern int mac_ogg_stream_flush(ogg_stream_state *os, ogg_page *og); -extern int mac_ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); -extern int mac_ogg_page_eos(ogg_page *og); -extern int mac_ogg_stream_clear(ogg_stream_state *os); - - -#ifdef __cplusplus -} -#endif diff --git a/indra/newview/build_win32_appConfig.py b/indra/newview/build_win32_appConfig.py deleted file mode 100755 index 1bfcc7a9bc..0000000000 --- a/indra/newview/build_win32_appConfig.py +++ /dev/null @@ -1,68 +0,0 @@ -# @file build_win32_appConfig.py -# @brief Create the windows app.config file to redirect crt linkage. -# -# $LicenseInfo:firstyear=2009&license=viewerlgpl$ -# Second Life Viewer Source Code -# Copyright (C) 2010, Linden Research, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; -# version 2.1 of the License only. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# -# Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -# $/LicenseInfo$ - -import sys, os, re -from xml.dom.minidom import parse - -def munge_binding_redirect_version(src_manifest_name, src_config_name, dst_config_name): - manifest_dom = parse(src_manifest_name) - node = manifest_dom.getElementsByTagName('assemblyIdentity')[0] - manifest_assm_ver = node.getAttribute('version') - - config_dom = parse(src_config_name) - node = config_dom.getElementsByTagName('bindingRedirect')[0] - node.setAttribute('newVersion', manifest_assm_ver) - src_old_ver = re.match('([^-]*-).*', node.getAttribute('oldVersion')).group(1) - node.setAttribute('oldVersion', src_old_ver + manifest_assm_ver) - comment = config_dom.createComment("This file is automatically generated by the build. see indra/newview/build_win32_appConfig.py") - config_dom.insertBefore(comment, config_dom.childNodes[0]) - - print("Writing: " + dst_config_name) - f = open(dst_config_name, 'w') - config_dom.writexml(f) - f.close() - - - -def main(): - config = sys.argv[1] - src_dir = sys.argv[2] - dst_dir = sys.argv[3] - dst_name = sys.argv[4] - - if config.lower() == 'debug': - src_manifest_name = dst_dir + '/Microsoft.VC80.DebugCRT.manifest' - src_config_name = src_dir + '/SecondLifeDebug.exe.config' - else: - src_manifest_name = dst_dir + '/Microsoft.VC80.CRT.manifest' - src_config_name = src_dir + '/SecondLife.exe.config' - - dst_config_name = dst_dir + '/' + dst_name - - munge_binding_redirect_version(src_manifest_name, src_config_name, dst_config_name) - - return 0 - -if __name__ == "__main__": - main() diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index 6e56aac270..a5ab5538e7 100644 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -31,8 +31,6 @@ /* own header */ #include "lllocalbitmaps.h" -/* boost: will not compile unless equivalent is undef'd, beware. */ -#include "fix_macros.h" #include /* image compression headers. */ diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index d6facad23d..aeae7cb56a 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -30,8 +30,6 @@ /* own header */ #include "lllocalgltfmaterials.h" -/* boost: will not compile unless equivalent is undef'd, beware. */ -#include "fix_macros.h" #include /* time headers */ diff --git a/indra/newview/macutil_Prefix.h b/indra/newview/macutil_Prefix.h deleted file mode 100644 index 4972ee4fa5..0000000000 --- a/indra/newview/macutil_Prefix.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file macutil_Prefix.h - * @brief Precompiled prefix file - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/* - * - * Precompiled prefix file used for - * AutoUpdater - * crashreporter - * - */ - -#include "fix_macros.h" - -#undef verify -#undef require diff --git a/indra/newview/macview_Prefix.h b/indra/newview/macview_Prefix.h deleted file mode 100644 index faad8fa704..0000000000 --- a/indra/newview/macview_Prefix.h +++ /dev/null @@ -1,229 +0,0 @@ -/** - * @file macview_Prefix.h - * @brief Prefix header for all source files of the 'newview' target in the 'newview' project. - * - * $LicenseInfo:firstyear=2003&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -// MBW -- This doesn't work. There are some conflicts between things in Carbon.h and some of the linden source. -//#include - -////////////////// From llagent.cpp -#include "llpreprocessor.h" -#include "stdtypes.h" -#include "stdenums.h" - -#include "llagent.h" - -#include "llcoordframe.h" -#include "indra_constants.h" -#include "llmath.h" -#include "llcriticaldamp.h" -#include "llfocusmgr.h" -#include "llparcel.h" -#include "llpermissions.h" -#include "llregionhandle.h" -#include "m3math.h" -#include "m4math.h" -#include "message.h" -#include "qmath.h" -#include "v3math.h" -#include "v4math.h" -#include "vmath.h" -//#include "llteleportflags.h" - -#include "llbox.h" -#include "llbutton.h" -#include "llconsole.h" -#include "lldrawable.h" -#include "llfirstuse.h" -#include "llfloater.h" -#include "llfloaterbuildoptions.h" -#include "llfloaterchat.h" -#include "llfloatergroups.h" -#include "llfloaterworldmap.h" -#include "llfloatermute.h" -#include "llconversation.h" -#include "llfloatertools.h" -#include "llhudeffectlookat.h" -#include "llhudmanager.h" -#include "lljoystickbutton.h" -#include "llmenugl.h" -#include "llmorphview.h" -#include "llmoveview.h" -#include "llselectmgr.h" -#include "llsky.h" -#include "llrendersphere.h" -#include "llstatusbar.h" -#include "lltalkview.h" -#include "lltool.h" -#include "lltoolfocus.h" -#include "lltoolcomp.h" // for gToolGun -#include "lltoolgrab.h" -#include "lltoolmgr.h" -#include "lltoolpie.h" -#include "llui.h" // for make_ui_sound -#include "llviewercamera.h" -#include "llviewermenu.h" -#include "llviewerobjectlist.h" -#include "llviewerparcelmgr.h" -#include "llviewerparceloverlay.h" -#include "llviewerregion.h" -#include "llviewerstats.h" -#include "llviewerwindow.h" -#include "llvoavatar.h" -#include "llvoground.h" -#include "llvosky.h" -#include "llworld.h" -#include "pipeline.h" - -/////////////////// From llfloater.cpp -#include "llbutton.h" -#include "lldraghandle.h" -#include "llfocusmgr.h" -#include "llresizebar.h" -#include "llresizehandle.h" -#include "llresmgr.h" -#include "llui.h" -#include "llviewborder.h" -#include "lluictrlfactory.h" - - -/////////////////// From lldrawpool.cpp -#include "llface.h" -#include "llcontrol.h" -#include "pipeline.h" - -#include "llviewerobjectlist.h" // For debug listing. - -//extern LLPipeline gPipeline; - -#include "lldrawpoolsimple.h" -#include "lldrawpoolalpha.h" -#include "lldrawpoolavatar.h" -#include "lldrawpooltree.h" -#include "lldrawpoolterrain.h" -#include "lldrawpoolsky.h" -#include "lldrawpoolwater.h" -#include "lldrawpoolground.h" -#include "lldrawpoolbump.h" - -/////////////////// From llface.cpp -#include "llgl.h" -#include "llviewerimage.h" -#include "llsky.h" -#include "llvosky.h" -#include "llcontrol.h" -#include "v3color.h" -#include "pipeline.h" -#include "llvolume.h" -#include "llviewercamera.h" -#include "lllightconstants.h" - -#include "llvovolume.h" -#include "m3math.h" -#include "lldrawpoolbump.h" - - - -/////////////////// From llpanel.cpp -#include "llpanel.h" - -#include "llfontgl.h" -#include "llrect.h" -#include "llerror.h" -#include "lltimer.h" - -#include "llmenugl.h" -#include "llstatusbar.h" -#include "llui.h" -#include "llkeyboard.h" -#include "llviewerwindow.h" -#include "llcontrol.h" -#include "lluictrl.h" -#include "lluictrlfactory.h" -#include "llviewborder.h" -#include "llviewerimagelist.h" -#include "llbutton.h" -#include "llfocusmgr.h" - - - -/////////////////// From llvovolume.cpp -#include "llvovolume.h" -#include "llviewerimagelist.h" - -#include "llcontrol.h" - -#include "object_flags.h" - -#include "material_codes.h" -#include "llagent.h" -#include "llworld.h" -#include "llviewerregion.h" -#include "llprimitive.h" -#include "llvolume.h" -#include "lldrawable.h" -#include "llface.h" -#include "llvolumemgr.h" -#include "llsky.h" - -#include "pipeline.h" -#include "llmaterialtable.h" -#include "message.h" -#include "llviewertextureanim.h" -#include "llviewercamera.h" -#include "lldrawpoolbump.h" - - -/////////////////// From llagentpilot.cpp -#include "llagentpilot.h" -#include "llagent.h" -#include "llframestats.h" -#include "viewer.h" -#include "llcontrol.h" - - -/////////////////// From llloginview.cpp -#include "llloginview.h" - -#include "indra_constants.h" // for key and mask constants -#include "llfontgl.h" -#include "v4color.h" -#include "llwindow_impl.h" - -#include "llbutton.h" -#include "llcheckboxctrl.h" -#include "llcombobox.h" -#include "llcontrol.h" -#include "lllineeditor.h" -#include "lltextbox.h" -#include "llui.h" -//#include "lluiconstants.h" -#include "llviewerimagelist.h" -#include "llviewermenu.h" // for handle_preferences() -#include "llviewerwindow.h" // to link into child list -#include "llfocusmgr.h" -#include "llmd5.h" -#include "llversion.h" -#include "viewer.h" - diff --git a/indra/test/test.cpp b/indra/test/test.cpp index fd8034b811..d515cea3fa 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -46,13 +46,6 @@ #include "apr_pools.h" #include "apr_getopt.h" -// the CTYPE_WORKAROUND is needed for linux dev stations that don't -// have the broken libc6 packages needed by our out-of-date static -// libs (such as libcrypto and libcurl). -- Leviathan 20060113 -#ifdef CTYPE_WORKAROUND -# include "ctype_workaround.h" -#endif - #include #include @@ -619,10 +612,6 @@ int main(int argc, char **argv) LLFile::remove(test_log); LLError::logToFile(test_log); -#ifdef CTYPE_WORKAROUND - ctype_workaround(); -#endif - if (!sMasterThreadRecorder) { sMasterThreadRecorder = new LLTrace::ThreadRecorder(); -- cgit v1.3 From 7bb5ea40b86d6d8baef0b24f9dabb21f6fdb3d2b Mon Sep 17 00:00:00 2001 From: Rye Date: Mon, 15 Dec 2025 15:07:30 -0500 Subject: Clean up dead LLSphere code and related tests Signed-off-by: Rye --- indra/llmath/CMakeLists.txt | 2 - indra/llmath/llsphere.cpp | 370 ----------------------------------- indra/llmath/llsphere.h | 77 -------- indra/llmath/tests/mathmisc_test.cpp | 161 --------------- indra/newview/llvoicevisualizer.cpp | 1 - 5 files changed, 611 deletions(-) delete mode 100644 indra/llmath/llsphere.cpp delete mode 100644 indra/llmath/llsphere.h (limited to 'indra/llmath') diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index a4e4d0a50b..f97e4a5bb6 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -24,7 +24,6 @@ set(llmath_SOURCE_FILES llquaternion.cpp llrigginginfo.cpp llrect.cpp - llsphere.cpp llvector4a.cpp llvolume.cpp llvolumemgr.cpp @@ -72,7 +71,6 @@ set(llmath_HEADER_FILES llsimdmath.h llsimdtypes.h llsimdtypes.inl - llsphere.h lltreenode.h llvector4a.h llvector4a.inl diff --git a/indra/llmath/llsphere.cpp b/indra/llmath/llsphere.cpp deleted file mode 100644 index 5f48764455..0000000000 --- a/indra/llmath/llsphere.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/** - * @file llsphere.cpp - * @author Andrew Meadows - * @brief Simple line class that can compute nearest approach between two lines - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llsphere.h" - -LLSphere::LLSphere() -: mCenter(0.f, 0.f, 0.f), - mRadius(0.f) -{ } - -LLSphere::LLSphere( const LLVector3& center, F32 radius) -{ - set(center, radius); -} - -void LLSphere::set( const LLVector3& center, F32 radius ) -{ - mCenter = center; - setRadius(radius); -} - -void LLSphere::setCenter( const LLVector3& center) -{ - mCenter = center; -} - -void LLSphere::setRadius( F32 radius) -{ - if (radius < 0.f) - { - radius = -radius; - } - mRadius = radius; -} - -const LLVector3& LLSphere::getCenter() const -{ - return mCenter; -} - -F32 LLSphere::getRadius() const -{ - return mRadius; -} - -// returns 'true' if this sphere completely contains other_sphere -bool LLSphere::contains(const LLSphere& other_sphere) const -{ - F32 separation = (mCenter - other_sphere.mCenter).length(); - return mRadius >= separation + other_sphere.mRadius; -} - -// returns 'true' if this sphere completely contains other_sphere -bool LLSphere::overlaps(const LLSphere& other_sphere) const -{ - F32 separation = (mCenter - other_sphere.mCenter).length(); - return mRadius >= separation - other_sphere.mRadius; -} - -// returns overlap -// negative overlap is closest approach -F32 LLSphere::getOverlap(const LLSphere& other_sphere) const -{ - // separation is distance from other_sphere's edge and this center - return (mCenter - other_sphere.mCenter).length() - mRadius - other_sphere.mRadius; -} - -bool LLSphere::operator==(const LLSphere& rhs) const -{ - return fabs(mRadius - rhs.mRadius) <= FLT_EPSILON && - (mCenter - rhs.mCenter).length() <= FLT_EPSILON; -} - -std::ostream& operator<<( std::ostream& output_stream, const LLSphere& sphere) -{ - output_stream << "{center=" << sphere.mCenter << "," << "radius=" << sphere.mRadius << "}"; - return output_stream; -} - -// static -// removes any spheres that are contained in others -void LLSphere::collapse(std::vector& sphere_list) -{ - std::vector::iterator first_itr = sphere_list.begin(); - while (first_itr != sphere_list.end()) - { - bool delete_from_front = false; - - std::vector::iterator second_itr = first_itr; - ++second_itr; - while (second_itr != sphere_list.end()) - { - if (second_itr->contains(*first_itr)) - { - delete_from_front = true; - break; - } - else if (first_itr->contains(*second_itr)) - { - sphere_list.erase(second_itr++); - } - else - { - ++second_itr; - } - } - - if (delete_from_front) - { - sphere_list.erase(first_itr++); - } - else - { - ++first_itr; - } - } -} - -// static -// returns the bounding sphere that contains both spheres -LLSphere LLSphere::getBoundingSphere(const LLSphere& first_sphere, const LLSphere& second_sphere) -{ - LLVector3 direction = second_sphere.mCenter - first_sphere.mCenter; - - // HACK -- it is possible to get enough floating point error in the - // other getBoundingSphere() method that we have to add some slop - // at the end. Unfortunately, this breaks the link-order invarience - // for the linkability tests... unless we also apply the same slop - // here. - F32 half_milimeter = 0.0005f; - - F32 distance = direction.length(); - if (0.f == distance) - { - direction.setVec(1.f, 0.f, 0.f); - } - else - { - direction.normVec(); - } - // the 'edge' is measured from the first_sphere's center - F32 max_edge = 0.f; - F32 min_edge = 0.f; - - max_edge = llmax(max_edge + first_sphere.getRadius(), max_edge + distance + second_sphere.getRadius() + half_milimeter); - min_edge = llmin(min_edge - first_sphere.getRadius(), min_edge + distance - second_sphere.getRadius() - half_milimeter); - F32 radius = 0.5f * (max_edge - min_edge); - LLVector3 center = first_sphere.mCenter + (0.5f * (max_edge + min_edge)) * direction; - return LLSphere(center, radius); -} - -// static -// returns the bounding sphere that contains an arbitrary set of spheres -LLSphere LLSphere::getBoundingSphere(const std::vector& sphere_list) -{ - // this algorithm can get relatively inaccurate when the sphere - // collection is 'small' (contained within a bounding sphere of about - // 2 meters or less) - // TODO -- improve the accuracy for small collections of spheres - - LLSphere bounding_sphere( LLVector3(0.f, 0.f, 0.f), 0.f ); - auto sphere_count = sphere_list.size(); - if (1 == sphere_count) - { - // trivial case -- single sphere - std::vector::const_iterator sphere_itr = sphere_list.begin(); - bounding_sphere = *sphere_itr; - } - else if (2 == sphere_count) - { - // trivial case -- two spheres - std::vector::const_iterator first_sphere = sphere_list.begin(); - std::vector::const_iterator second_sphere = first_sphere; - ++second_sphere; - bounding_sphere = LLSphere::getBoundingSphere(*first_sphere, *second_sphere); - } - else if (sphere_count > 0) - { - // non-trivial case -- we will approximate the solution - // - // NOTE -- there is a fancy/fast way to do this for large - // numbers of arbirary N-dimensional spheres -- you can look it - // up on the net. We're dealing with 3D spheres at collection - // sizes of 256 spheres or smaller, so we just use this - // brute force method. - - // TODO -- perhaps would be worthwile to test for the solution where - // the largest spanning radius just happens to work. That is, where - // there are really two spheres that determine the bounding sphere, - // and all others are contained therein. - - // compute the AABB - std::vector::const_iterator first_itr = sphere_list.begin(); - LLVector3 max_corner = first_itr->getCenter() + first_itr->getRadius() * LLVector3(1.f, 1.f, 1.f); - LLVector3 min_corner = first_itr->getCenter() - first_itr->getRadius() * LLVector3(1.f, 1.f, 1.f); - { - std::vector::const_iterator sphere_itr = sphere_list.begin(); - for (++sphere_itr; sphere_itr != sphere_list.end(); ++sphere_itr) - { - LLVector3 center = sphere_itr->getCenter(); - F32 radius = sphere_itr->getRadius(); - for (S32 i=0; i<3; ++i) - { - if (center.mV[i] + radius > max_corner.mV[i]) - { - max_corner.mV[i] = center.mV[i] + radius; - } - if (center.mV[i] - radius < min_corner.mV[i]) - { - min_corner.mV[i] = center.mV[i] - radius; - } - } - } - } - - // get the starting center and radius from the AABB - LLVector3 diagonal = max_corner - min_corner; - F32 bounding_radius = 0.5f * diagonal.length(); - LLVector3 bounding_center = 0.5f * (max_corner + min_corner); - - // compute the starting step-size - F32 minimum_radius = 0.5f * llmin(diagonal.mV[VX], llmin(diagonal.mV[VY], diagonal.mV[VZ])); - F32 step_length = bounding_radius - minimum_radius; - //S32 step_count = 0; - //S32 max_step_count = 12; - F32 half_milimeter = 0.0005f; - - // wander the center around in search of tighter solutions - S32 last_dx = 2; // 2 is out of bounds --> no match - S32 last_dy = 2; - S32 last_dz = 2; - - while (step_length > half_milimeter - /*&& step_count < max_step_count*/) - { - // the algorithm for testing the maximum radius could be expensive enough - // that it makes sense to NOT duplicate testing when possible, so we keep - // track of where we last tested, and only test the new points - - S32 best_dx = 0; - S32 best_dy = 0; - S32 best_dz = 0; - - // sample near the center of the box - bool found_better_center = false; - for (S32 dx = -1; dx < 2; ++dx) - { - for (S32 dy = -1; dy < 2; ++dy) - { - for (S32 dz = -1; dz < 2; ++dz) - { - if (dx == 0 && dy == 0 && dz == 0) - { - continue; - } - - // count the number of indecies that match the last_*'s - S32 match_count = 0; - if (last_dx == dx) ++match_count; - if (last_dy == dy) ++match_count; - if (last_dz == dz) ++match_count; - if (match_count == 2) - { - // we've already tested this point - continue; - } - - LLVector3 center = bounding_center; - center.mV[VX] += (F32) dx * step_length; - center.mV[VY] += (F32) dy * step_length; - center.mV[VZ] += (F32) dz * step_length; - - // compute the radius of the bounding sphere - F32 max_radius = 0.f; - std::vector::const_iterator sphere_itr; - for (sphere_itr = sphere_list.begin(); sphere_itr != sphere_list.end(); ++sphere_itr) - { - F32 radius = (sphere_itr->getCenter() - center).length() + sphere_itr->getRadius(); - if (radius > max_radius) - { - max_radius = radius; - } - } - if (max_radius < bounding_radius) - { - best_dx = dx; - best_dy = dy; - best_dz = dz; - bounding_center = center; - bounding_radius = max_radius; - found_better_center = true; - } - } - } - } - if (found_better_center) - { - // remember where we came from so we can avoid retesting - last_dx = -best_dx; - last_dy = -best_dy; - last_dz = -best_dz; - } - else - { - // reduce the step size - step_length *= 0.5f; - //++step_count; - // reset the last_*'s - last_dx = 2; // 2 is out of bounds --> no match - last_dy = 2; - last_dz = 2; - } - } - - // HACK -- it is possible to get enough floating point error for the - // bounding sphere to too small on the order of 10e-6, but we only need - // it to be accurate to within about half a millimeter - bounding_radius += half_milimeter; - - // this algorithm can get relatively inaccurate when the sphere - // collection is 'small' (contained within a bounding sphere of about - // 2 meters or less) - // TODO -- fix this - /* debug code - { - std::vector::const_iterator sphere_itr; - for (sphere_itr = sphere_list.begin(); sphere_itr != sphere_list.end(); ++sphere_itr) - { - F32 radius = (sphere_itr->getCenter() - bounding_center).length() + sphere_itr->getRadius(); - if (radius + 0.1f > bounding_radius) - { - std::cout << " rad = " << radius << " bounding - rad = " << (bounding_radius - radius) << std::endl; - } - } - std::cout << "\n" << std::endl; - } - */ - - bounding_sphere.set(bounding_center, bounding_radius); - } - return bounding_sphere; -} - - diff --git a/indra/llmath/llsphere.h b/indra/llmath/llsphere.h deleted file mode 100644 index cb923dcd3c..0000000000 --- a/indra/llmath/llsphere.h +++ /dev/null @@ -1,77 +0,0 @@ -// llsphere.h -/** - * @file llsphere.cpp - * @author Andrew Meadows - * @brief Simple sphere implementation for basic geometric operations - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_SPHERE_H -#define LL_SPHERE_H - -#include "stdtypes.h" -#include "v3math.h" -#include -#include - -class LLSphere -{ -public: - LLSphere(); - LLSphere( const LLVector3& center, F32 radius ); - - void set( const LLVector3& center, F32 radius ); - void setCenter( const LLVector3& center ); - void setRadius( F32 radius ); - - const LLVector3& getCenter() const; - F32 getRadius() const; - - // returns true if this sphere completely contains other_sphere - bool contains(const LLSphere& other_sphere) const; - - // returns true if this sphere overlaps other_sphere - bool overlaps(const LLSphere& other_sphere) const; - - // returns overlap distance - // negative overlap is closest approach - F32 getOverlap(const LLSphere& other_sphere) const; - - // removes any spheres that are contained in others - static void collapse(std::vector& sphere_list); - - // returns minimum sphere bounding sphere for a set of spheres - static LLSphere getBoundingSphere(const LLSphere& first_sphere, const LLSphere& second_sphere); - static LLSphere getBoundingSphere(const std::vector& sphere_list); - - bool operator==(const LLSphere& rhs) const; - - friend std::ostream& operator<<( std::ostream& output_stream, const LLSphere& line ); - -protected: - LLVector3 mCenter; - F32 mRadius; -}; - - -#endif diff --git a/indra/llmath/tests/mathmisc_test.cpp b/indra/llmath/tests/mathmisc_test.cpp index ff0899e975..810b0d80da 100644 --- a/indra/llmath/tests/mathmisc_test.cpp +++ b/indra/llmath/tests/mathmisc_test.cpp @@ -35,7 +35,6 @@ #include "../llline.h" #include "../llmath.h" -#include "../llsphere.h" #include "../v3math.h" namespace tut @@ -278,166 +277,6 @@ namespace tut } } -namespace tut -{ - struct sphere_data - { - }; - typedef test_group sphere_test; - typedef sphere_test::object sphere_object; - tut::sphere_test tsphere("LLSphere"); - - template<> template<> - void sphere_object::test<1>() - { - // test LLSphere::contains() and ::overlaps() - S32 number_of_tests = 10; - for (S32 test = 0; test < number_of_tests; ++test) - { - LLVector3 first_center(1.f, 1.f, 1.f); - F32 first_radius = 3.f; - LLSphere first_sphere( first_center, first_radius ); - - F32 half_millimeter = 0.0005f; - LLVector3 direction( ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f); - direction.normalize(); - - F32 distance = ll_frand(first_radius - 2.f * half_millimeter); - LLVector3 second_center = first_center + distance * direction; - F32 second_radius = first_radius - distance - half_millimeter; - LLSphere second_sphere( second_center, second_radius ); - ensure("first sphere should contain the second", first_sphere.contains(second_sphere)); - ensure("first sphere should overlap the second", first_sphere.overlaps(second_sphere)); - - distance = first_radius + ll_frand(first_radius); - second_center = first_center + distance * direction; - second_radius = distance - first_radius + half_millimeter; - second_sphere.set( second_center, second_radius ); - ensure("first sphere should NOT contain the second", !first_sphere.contains(second_sphere)); - ensure("first sphere should overlap the second", first_sphere.overlaps(second_sphere)); - - distance = first_radius + ll_frand(first_radius) + half_millimeter; - second_center = first_center + distance * direction; - second_radius = distance - first_radius - half_millimeter; - second_sphere.set( second_center, second_radius ); - ensure("first sphere should NOT contain the second", !first_sphere.contains(second_sphere)); - ensure("first sphere should NOT overlap the second", !first_sphere.overlaps(second_sphere)); - } - } - - template<> template<> - void sphere_object::test<2>() - { - skip("See SNOW-620. Neither the test nor the code being tested seem good. Also sim-only."); - - // test LLSphere::getBoundingSphere() - S32 number_of_tests = 100; - S32 number_of_spheres = 10; - F32 sphere_center_range = 32.f; - F32 sphere_radius_range = 5.f; - - for (S32 test = 0; test < number_of_tests; ++test) - { - // gegnerate a bunch of random sphere - std::vector< LLSphere > sphere_list; - for (S32 sphere_count=0; sphere_count < number_of_spheres; ++sphere_count) - { - LLVector3 direction( ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f, ll_frand(2.f) - 1.f); - direction.normalize(); - F32 distance = ll_frand(sphere_center_range); - LLVector3 center = distance * direction; - F32 radius = ll_frand(sphere_radius_range); - LLSphere sphere( center, radius ); - sphere_list.push_back(sphere); - } - - // compute the bounding sphere - LLSphere bounding_sphere = LLSphere::getBoundingSphere(sphere_list); - - // make sure all spheres are inside the bounding sphere - { - std::vector< LLSphere >::const_iterator sphere_itr; - for (sphere_itr = sphere_list.begin(); sphere_itr != sphere_list.end(); ++sphere_itr) - { - ensure("sphere should be contained by the bounding sphere", bounding_sphere.contains(*sphere_itr)); - } - } - - // TODO -- improve LLSphere::getBoundingSphere() to the point where - // we can reduce the 'expansion' in the two tests below to about - // 2 mm or less - - F32 expansion = 0.005f; - // move all spheres out a little bit - // and count how many are NOT contained - { - std::vector< LLVector3 > uncontained_directions; - std::vector< LLSphere >::iterator sphere_itr; - for (sphere_itr = sphere_list.begin(); sphere_itr != sphere_list.end(); ++sphere_itr) - { - LLVector3 direction = sphere_itr->getCenter() - bounding_sphere.getCenter(); - direction.normalize(); - - sphere_itr->setCenter( sphere_itr->getCenter() + expansion * direction ); - if (! bounding_sphere.contains( *sphere_itr ) ) - { - uncontained_directions.push_back(direction); - } - } - ensure("when moving spheres out there should be at least two uncontained spheres", - uncontained_directions.size() > 1); - - /* TODO -- when the bounding sphere algorithm is improved we can open up this test - * at the moment it occasionally fails when the sphere collection is tight and small - * (2 meters or less) - if (2 == uncontained_directions.size() ) - { - // if there were only two uncontained spheres then - // the two directions should be nearly opposite - F32 dir_dot = uncontained_directions[0] * uncontained_directions[1]; - ensure("two uncontained spheres should lie opposite the bounding center", dir_dot < -0.95f); - } - */ - } - - // compute the new bounding sphere - bounding_sphere = LLSphere::getBoundingSphere(sphere_list); - - // increase the size of all spheres a little bit - // and count how many are NOT contained - { - std::vector< LLVector3 > uncontained_directions; - std::vector< LLSphere >::iterator sphere_itr; - for (sphere_itr = sphere_list.begin(); sphere_itr != sphere_list.end(); ++sphere_itr) - { - LLVector3 direction = sphere_itr->getCenter() - bounding_sphere.getCenter(); - direction.normalize(); - - sphere_itr->setRadius( sphere_itr->getRadius() + expansion ); - if (! bounding_sphere.contains( *sphere_itr ) ) - { - uncontained_directions.push_back(direction); - } - } - ensure("when boosting sphere radii there should be at least two uncontained spheres", - uncontained_directions.size() > 1); - - /* TODO -- when the bounding sphere algorithm is improved we can open up this test - * at the moment it occasionally fails when the sphere collection is tight and small - * (2 meters or less) - if (2 == uncontained_directions.size() ) - { - // if there were only two uncontained spheres then - // the two directions should be nearly opposite - F32 dir_dot = uncontained_directions[0] * uncontained_directions[1]; - ensure("two uncontained spheres should lie opposite the bounding center", dir_dot < -0.95f); - } - */ - } - } - } -} - namespace tut { F32 SMALL_RADIUS = 1.0f; diff --git a/indra/newview/llvoicevisualizer.cpp b/indra/newview/llvoicevisualizer.cpp index c5704982b8..e6dac0530d 100644 --- a/indra/newview/llvoicevisualizer.cpp +++ b/indra/newview/llvoicevisualizer.cpp @@ -32,7 +32,6 @@ #include "llviewerprecompiledheaders.h" #include "llviewercontrol.h" #include "llglheaders.h" -#include "llsphere.h" #include "llvoicevisualizer.h" #include "llviewercamera.h" #include "llviewerobject.h" -- cgit v1.3 From 134bdc86cc82ff12fad125a8ffbb1c0b44a43a95 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Mon, 22 Jun 2026 19:20:43 +0300 Subject: #5945 cacheOptimize crash handling --- indra/llmath/llvolume.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index c74ea3e42b..8d7d201be1 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -2383,11 +2383,31 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) //copy out vertices U32 num_verts = static_cast(pos.size())/(3*2); + if (num_verts == 0) + { + LL_WARNS() << "Zero vertices for face index: " << i << LL_ENDL; + face.resizeIndices(3); + face.resizeVertices(1); + face.mPositions->clear(); + face.mNormals->clear(); + face.mTexCoords->setZero(); + memset(face.mIndices, 0, sizeof(U16) * 3); + continue; + } + + if (num_verts > 65535) // U16 indices + { + LL_WARNS() << "Invalid vertex count " << num_verts << " exceeds maximum for face index: " << i << LL_ENDL; + mVolumeFaces.clear(); + return false; + } + face.resizeVertices(num_verts); if (num_verts > 0 && !face.mPositions) { LL_WARNS() << "Failed to allocate " << num_verts << " vertices for face index: " << i << " Total: " << face_count << LL_ENDL; + face.resizeVertices(0); face.resizeIndices(0); continue; } @@ -5677,7 +5697,40 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) mOptimized = true; if (gen_tangents && mNormals && mTexCoords) - { // generate mikkt space tangents before cache optimizing since the index buffer may change + { + if (!mPositions || !mIndices || mNumVertices <= 0 || mNumIndices <= 0) + { + LL_WARNS_ONCE("LLVolume") << "Invalid volume face data for tangent generation: " + << "mPositions=" << (void*)mPositions + << ", mIndices=" << (void*)mIndices + << ", mNumVertices=" << mNumVertices + << ", mNumIndices=" << mNumIndices << LL_ENDL; + return false; + } + + if (mNumIndices % 3 != 0) + { + LL_WARNS_ONCE("LLVolume") << "Non-triangulated mesh, mNumIndices=" << mNumIndices << LL_ENDL; + return false; + } + + for (S32 i = 0; i < mNumIndices; ++i) + { + if (mIndices[i] >= mNumVertices) + { + LL_WARNS_ONCE("LLVolume") << "Out of bounds index detected: mIndices[" << i << "]=" + << mIndices[i] << " >= mNumVertices=" << mNumVertices << LL_ENDL; + return false; + } + } + + if (mNormalizedScale.mV[0] == 0.0f || mNormalizedScale.mV[1] == 0.0f || mNormalizedScale.mV[2] == 0.0f) + { + LL_WARNS_ONCE("LLVolume") << "Invalid normalized scale: " << mNormalizedScale << LL_ENDL; + return false; + } + + // generate mikkt space tangents before cache optimizing since the index buffer may change // a bit of a hack to do this here, but this function gets called exactly once for the lifetime of a mesh // and is executed on a background thread MikktData data(this); -- cgit v1.3 From 7a82e2619598ae6ed1a291d2f7257de8ea55185d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Wed, 24 Jun 2026 23:48:50 +0300 Subject: #3988 Don't render malformed sculpts --- indra/llmath/llvolume.cpp | 159 ++++++++++++++++++++++++++++++++++++++++++++-- indra/llmath/llvolume.h | 9 ++- 2 files changed, 163 insertions(+), 5 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 8d7d201be1..7d5cbee82a 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -1971,6 +1971,8 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const bool ge mNumHullIndices = 0; // set defaults + mSculptValidationCache.fill(LLSculptValidationState::Unvalidated); + if (mParams.getPathParams().getCurveType() == LL_PCODE_PATH_FLEXIBLE) { mPathp = new LLDynamicPath(); @@ -1998,6 +2000,13 @@ void LLVolume::resizePath(S32 length) setDirty(); } +void LLVolume::setDirty() +{ + mPathp->setDirty(); + mProfilep->setDirty(); + mSculptValidationCache.fill(LLSculptValidationState::Unvalidated); +} + void LLVolume::regen() { generate(); @@ -3158,10 +3167,100 @@ S32 sculpt_sides(F32 detail) } } +static bool validate_sculpt_geometry(const LLVolume* volume) +{ + if (!volume || volume->getNumVolumeFaces() == 0) + { + return true; + } + + // Validate each face in the sculpt + for (S32 face_idx = 0; face_idx < volume->getNumVolumeFaces(); ++face_idx) + { + const LLVolumeFace& face = volume->getVolumeFace(face_idx); + + // Skip validation for degenerate faces + if (face.mNumVertices < 3 || face.mNumIndices < 3) + { + continue; + } + + // Calculate 'bounding' surface + LLVector4a extent_size; + extent_size.setSub(face.mExtents[1], face.mExtents[0]); + + F32 width = extent_size[0]; + F32 height = extent_size[1]; + F32 depth = extent_size[2]; + + F32 bounding_surface = width * height + width * depth + height * depth; + bounding_surface *= 2; + + if (!llfinite(bounding_surface) || bounding_surface <= FLT_EPSILON) + { + return false; + } + + // Calculate total surface area of all triangles + F32 total_triangle_area = 0.0f; + S32 num_triangles = face.mNumIndices / 3; + + for (S32 i = 0; i < num_triangles; ++i) + { + S32 idx_base = i * 3; + U16 idx0 = face.mIndices[idx_base]; + U16 idx1 = face.mIndices[idx_base + 1]; + U16 idx2 = face.mIndices[idx_base + 2]; + + // Validate indices + if (idx0 >= face.mNumVertices || idx1 >= face.mNumVertices || idx2 >= face.mNumVertices) + { + continue; + } + + const LLVector4a& v0 = face.mPositions[idx0]; + const LLVector4a& v1 = face.mPositions[idx1]; + const LLVector4a& v2 = face.mPositions[idx2]; + + // Calculate triangle area + LLVector4a edge1, edge2, cross; + edge1.setSub(v1, v0); + edge2.setSub(v2, v0); + cross.setCross3(edge1, edge2); + + F32 triangle_area = cross.getLength3().getF32() * 0.5f; + total_triangle_area += triangle_area; + } + + if (!llfinite(total_triangle_area)) + { + return false; + } + + // The idea here is that the total area of a sculpt is normally comparable + // to the area of a bounding box. But a random overlapping collection of + // triangles has a significantly larger area than a sculpt normally has. + F32 area_ratio = total_triangle_area / bounding_surface; + constexpr F32 MAX_AREA_TO_AREA_RATIO = 16.0f; + if (area_ratio > MAX_AREA_TO_AREA_RATIO) + { + LL_DEBUGS("LLVOLUME") << "Sculpt rejected: excessive triangle area." + << " Face index: " << face_idx + << " Total triangle area: " << total_triangle_area << " sq m" + << " Bounding surface area: " << bounding_surface << " sq m" + << " Ratio: " << area_ratio + << " Triangle count: " << num_triangles + << " Bounds: [" << width << " x " << height << " x " << depth << "]" << LL_ENDL; + return false; + } + } + + return true; +} // determine the number of vertices in both s and t direction for this sculpt -void sculpt_calc_mesh_resolution(U16 width, U16 height, U8 type, F32 detail, S32& s, S32& t) +static void sculpt_calc_mesh_resolution(U16 width, U16 height, U8 type, F32 detail, S32& s, S32& t) { // this code has the following properties: // 1) the aspect ratio of the mesh is as close as possible to the ratio of the map @@ -3271,10 +3370,62 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, mSculptLevel = sculpt_level; - // Delete any existing faces so that they get regenerated - mVolumeFaces.clear(); + LLSculptValidationState cached_state = LLSculptValidationState::Valid; + if (!data_is_empty && (sculpt_level >= 0) && sculpt_level < SCULPT_CACHE_SIZE) + { + // validation might be expensive, so we do it only once per lod. + cached_state = mSculptValidationCache[sculpt_level]; + } - createVolumeFaces(); + switch (cached_state) + { + case LLSculptValidationState::Valid: + { + // Delete any existing faces, then regenerate + mVolumeFaces.clear(); + createVolumeFaces(); + break; + } + case LLSculptValidationState::Invalid: + { + // Invalid geometry + // Regenerate mesh with an empty placeholder + mVolumeFaces.clear(); + sculptGenerateEmptyPlaceholder(); + createVolumeFaces(); + break; + } + case LLSculptValidationState::Unvalidated: + { + // First time at this LOD + mVolumeFaces.clear(); + createVolumeFaces(); + + bool valid_geometry = true; + + // Todo: can this be backed into createVolumeFaces? + // Or calculated without having to call createVolumeFaces first? + // Todo 2: should the same be done for meshes? + valid_geometry = validate_sculpt_geometry(this); + mSculptValidationCache[sculpt_level] = valid_geometry ? LLSculptValidationState::Valid : LLSculptValidationState::Invalid; + + if (!valid_geometry) + { + LL_WARNS("LLVOLUME") << "Sculpt failed geometry validation - either invalid image or malicious. " + << "Replacing with placeholder. Image: " << mParams.getSculptID() << LL_ENDL; + + // Clear the malicious faces + mVolumeFaces.clear(); + + // Regenerate mesh with empty placeholder + sculptGenerateEmptyPlaceholder(); + + // Recreate faces with placeholder geometry + createVolumeFaces(); + } + break; + } + } //switch (cached_state) } diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index 3496928f7b..86a7bf0e6a 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -60,6 +60,8 @@ class LLVolumeOctree; #include "llalignedarray.h" #include "llrigginginfo.h" +#include + //============================================================================ constexpr S32 MIN_DETAIL_FACES = 6; @@ -1040,7 +1042,7 @@ public: const LLVector4a& getMeshPt(const U32 i) const { return mMesh[i]; } - void setDirty() { mPathp->setDirty(); mProfilep->setDirty(); } + void setDirty(); void regen(); void genTangents(S32 face); @@ -1131,6 +1133,11 @@ public: bool mIsMeshAssetLoaded; bool mIsMeshAssetUnavaliable; + // Cache for sculpt geometry validation results + static constexpr S32 SCULPT_CACHE_SIZE = 6; // 0 to 5 inclusive + enum class LLSculptValidationState : S8 { Unvalidated, Valid, Invalid }; + std::array mSculptValidationCache; + const LLVolumeParams mParams; LLPath *mPathp; LLProfile *mProfilep; -- cgit v1.3 From 9b7ab49575b54523128952af6686d17eb6696725 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> Date: Mon, 10 Aug 2026 22:46:38 +0300 Subject: #3814 Handle bad_allocs in unpackVolumeFaces --- indra/llmath/llvolume.cpp | 140 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 130 insertions(+), 10 deletions(-) (limited to 'indra/llmath') diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 7d5cbee82a..1bbc559763 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -52,6 +52,7 @@ #include "llmeshoptimizer.h" #include "lltimer.h" #include "llvolumeoctree.h" +#include "workqueue.h" #include "mikktspace/mikktspace.hh" @@ -2301,30 +2302,149 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + // Sanity-check before even trying to decompress + constexpr S32 MAX_MESH_COMPRESSED_SIZE = 128 * 1024 * 1024; // 128 MB + const LLUUID& mesh_id = getParams().getSculptID(); + + if (size <= 0 || size > MAX_MESH_COMPRESSED_SIZE) + { + LL_WARNS("MeshStreaming") << "Rejecting implausible compressed mesh size " << size + << " for mesh id " << mesh_id << LL_ENDL; + return false; + } + //input stream is now pointing at a zlib compressed block of LLSD //decompress block - LLSD mdl; - U32 uzip_result = LLUZipHelper::unzip_llsd(mdl, is, size); - if (uzip_result != LLUZipHelper::ZR_OK) + try + { + LLSD mdl; + U32 uzip_result = LLUZipHelper::unzip_llsd(mdl, is, size); + if (uzip_result != LLUZipHelper::ZR_OK) + { + LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD with code " << uzip_result << " , will probably fetch from sim again." << LL_ENDL; + return false; + } + return unpackVolumeFacesInternal(mdl); + } + catch (const std::bad_alloc&) + { + constexpr S32 SMALL_MESH_THRESHOLD = 4000; + if (size < SMALL_MESH_THRESHOLD) + { + // showOutOfMemory and LL_ERRS must run on the main thread. + // Post to mainloop WorkQueue, mirroring LLThread::tryRun(). + LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop"); + bool done = false; + if (main_queue) + { + const LLUUID mesh_id_copy = mesh_id; // capture by value for the lambda + done = main_queue->post([mesh_id_copy, size]() + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id_copy + << " of compressed size " << size << LL_ENDL; + }); + } + if (!done) + { + // No main queue available (e.g. during shutdown) + LL_WARNS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id + << " of compressed size " << size << " (main queue unavailable)" << LL_ENDL; + } + } + else + { + LL_WARNS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id + << " of compressed size " << size << LL_ENDL; + } + return false; + } + catch (const std::exception& e) { - LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD with code " << uzip_result << " , will probably fetch from sim again." << LL_ENDL; + LL_WARNS("MeshStreaming") << "Exception unpacking mesh id " << mesh_id + << " of compressed size " << size << ": " << e.what() << LL_ENDL; + return false; + } + catch (...) + { + LL_WARNS("MeshStreaming") << "Unknown exception unpacking mesh id " << mesh_id + << " of compressed size " << size << LL_ENDL; return false; } - return unpackVolumeFacesInternal(mdl); } bool LLVolume::unpackVolumeFaces(U8* in_data, S32 size) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + constexpr S32 MAX_MESH_COMPRESSED_SIZE = 128 * 1024 * 1024; // 128 MB + const LLUUID& mesh_id = getParams().getSculptID(); + + if (!in_data || size <= 0 || size > MAX_MESH_COMPRESSED_SIZE) + { + LL_WARNS("MeshStreaming") << "Rejecting implausible compressed mesh size " << size + << " for mesh id " << mesh_id << LL_ENDL; + return false; + } + //input data is now pointing at a zlib compressed block of LLSD //decompress block - LLSD mdl; - U32 uzip_result = LLUZipHelper::unzip_llsd(mdl, in_data, size); - if (uzip_result != LLUZipHelper::ZR_OK) + try + { + LLSD mdl; + U32 uzip_result = LLUZipHelper::unzip_llsd(mdl, in_data, size); + if (uzip_result != LLUZipHelper::ZR_OK) + { + LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD, mesh id " << mesh_id + << ", code " << uzip_result << " , will probably fetch from sim again." << LL_ENDL; + return false; + } + return unpackVolumeFacesInternal(mdl); + } + catch (const std::bad_alloc&) + { + constexpr S32 SMALL_MESH_THRESHOLD = 4000; + if (size < SMALL_MESH_THRESHOLD) + { + // showOutOfMemory and LL_ERRS must run on the main thread. + // Post to mainloop WorkQueue, mirroring LLThread::tryRun(). + LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop"); + bool done = false; + if (main_queue) + { + const LLUUID mesh_id_copy = mesh_id; // capture by value for the lambda + done = main_queue->post([mesh_id_copy, size]() + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id_copy + << " of compressed size " << size << LL_ENDL; + }); + } + if (!done) + { + // No main queue available (e.g. during shutdown) + LL_WARNS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id + << " of compressed size " << size << " (main queue unavailable)" << LL_ENDL; + } + } + else + { + LL_WARNS("MeshStreaming") << "Out of memory unpacking mesh id " << mesh_id + << " of compressed size " << size << LL_ENDL; + } + return false; + } + catch (const std::exception& e) + { + LL_WARNS("MeshStreaming") << "Exception unpacking mesh id " << mesh_id + << " of compressed size " << size << ": " << e.what() << LL_ENDL; + return false; + } + catch (...) { - LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD with code " << uzip_result << " , will probably fetch from sim again." << LL_ENDL; + LL_WARNS("MeshStreaming") << "Unknown exception unpacking mesh id " << mesh_id + << " of compressed size " << size << LL_ENDL; return false; } - return unpackVolumeFacesInternal(mdl); } bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) -- cgit v1.3