diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 74051ddd1dd..2a63c0213c7 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -33,9 +33,7 @@ jobs: strategy: fail-fast: false matrix: - # macos-13 is Intel runner, macos-14 is Apple Silicon - # https://github.com/actions/runner-images - os: [macos-13, macos-14] + os: [macos-14] CONFIG: [ON, OFF] env: BUILD_SHARED_LIBS: ${{ matrix.CONFIG }} @@ -118,50 +116,6 @@ jobs: path: build/bin/open3d-*-app-macosx-10_15-${{ runner.arch }}.zip if-no-files-found: error - fuse-viewer: - permissions: - contents: write # Release upload - name: Fuse x64 and ARM64 viewer app - runs-on: [macos-13] - needs: [MacOS] - steps: - - name: Checkout source code # for gh release upload - uses: actions/checkout@v4 - - name: Download viewer apps - uses: actions/download-artifact@v4 - with: - pattern: open3d-app-macosx-10_15-* - merge-multiple: true - - - name: Fuse x64 and arm64 viewer apps - run: | - unzip open3d-*-app-macosx-10_15-X64.zip -d x64 - unzip open3d-*-app-macosx-10_15-ARM64.zip -d arm64 - APP_NAME=$(ls open3d-*-app-macosx-10_15-X64.zip) - APP_NAME=${APP_NAME/-X64/-universal2} # includes version - for i in arm64/Open3D.app/Contents/MacOS/*; do - filepath=Open3D.app/Contents/MacOS/$(basename $i) - lipo -create arm64/${filepath} x64/${filepath} -output arm64/${filepath} - done - mv arm64/Open3D.app Open3D.app - zip -rv "${APP_NAME}" Open3D.app - - - name: Upload Open3D viewer app - uses: actions/upload-artifact@v4 - with: - name: open3d-app-macosx-10_15-universal2 - path: open3d-*-app-macosx-10_15-universal2.zip - if-no-files-found: error - - - name: Update viewer devel release - if: ${{ github.ref == 'refs/heads/main' }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload main-devel open3d-*-app-macosx-10_15-universal2.zip --clobber - gh release view main-devel - - build-wheel: name: Build wheel permissions: @@ -171,9 +125,7 @@ jobs: fail-fast: false # https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6 matrix: - # macos-13 is Intel runner, macos-14 is Apple Silicon - # https://github.com/actions/runner-images - os: [macos-13, macos-14] + os: [macos-14] python_version: ['3.10', '3.11', '3.12', '3.13'] is_main: - ${{ github.ref == 'refs/heads/main' }} @@ -257,75 +209,6 @@ jobs: path: build/lib/python_package/pip_package/${{ env.PIP_PKG_NAME }} if-no-files-found: error - - fuse-wheel: - name: Fuse universal2 wheel - permissions: - contents: write # Release upload - runs-on: [macos-13] - needs: [build-wheel] - strategy: - fail-fast: false - # https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6 - matrix: - python_version: ['3.10', '3.11', '3.12', '3.13'] - is_main: - - ${{ github.ref == 'refs/heads/main' }} - exclude: - - is_main: false - python_version: '3.10' - - is_main: false - python_version: '3.11' - - is_main: false - python_version: '3.12' - steps: - - name: Checkout source code # for gh release upload - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python_version }} - - - name: Download X64 wheels - uses: actions/download-artifact@v4 - with: - pattern: open3d-*macosx*_x86_64.whl - path: x64_wheels - merge-multiple: true - - - name: Download ARM64 wheels - uses: actions/download-artifact@v4 - with: - pattern: open3d-*macosx*_arm64.whl - path: arm64_wheels - merge-multiple: true - - - name: Fuse x64 and ARM64 wheels - env: - python_version: ${{ matrix.python_version }} - run: | - PYTAG="-cp$(echo ${{ env.python_version }} | tr -d '.')" - mkdir universal_wheels - pip install delocate - delocate-merge -v -w universal_wheels x64_wheels/open3d-*${PYTAG}*.whl arm64_wheels/open3d-*${PYTAG}*.whl - NEW_WHL_NAME=$(basename universal_wheels/open3d-*${PYTAG}*.whl) - echo "PIP_PKG_NAME=$NEW_WHL_NAME" >> $GITHUB_ENV - - - name: Upload merged wheels - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PIP_PKG_NAME }} - path: universal_wheels/${{ env.PIP_PKG_NAME }} - if-no-files-found: error - - - name: Update devel release - if: ${{ github.ref == 'refs/heads/main' }} - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release upload main-devel universal_wheels/${{ env.PIP_PKG_NAME }} --clobber - gh release view main-devel - test-wheel: name: Test wheel permissions: @@ -335,7 +218,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, macos-14] + os: [macos-14] python_version: ['3.10', '3.11', '3.12', '3.13'] is_main: - ${{ github.ref == 'refs/heads/main' }} diff --git a/.github/workflows/ubuntu-sycl.yml b/.github/workflows/ubuntu-sycl.yml index fe4132abffc..7bbb82c59fe 100644 --- a/.github/workflows/ubuntu-sycl.yml +++ b/.github/workflows/ubuntu-sycl.yml @@ -38,6 +38,19 @@ jobs: run: | source util/ci_utils.sh maximize_ubuntu_github_actions_build_space + - name: Free up disk space + if: ${{ runner.os == 'Linux' }} + # https://github.com/easimon/maximize-build-space/blob/master/action.yml + # https://github.com/easimon/maximize-build-space/tree/test-report + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache/CodeQL + - name: Set up swap space + if: runner.os == 'Linux' + uses: pierotofy/set-swap-space@v1.0 + with: + swap-size-gb: 10 - name: Docker build run: | if [ "${{ matrix.BUILD_SHARED_LIBS }}" = "ON" ]; then @@ -69,7 +82,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | if [ ${{ matrix.BUILD_SHARED_LIBS }} == 'ON' ] ; then - gh release upload main-devel open3d-*.whl --clobber + gh release upload main-devel open3d*.whl --clobber gh release upload main-devel open3d-devel-*.tar.xz --clobber fi gh release view main-devel diff --git a/3rdparty/embree/embree.cmake b/3rdparty/embree/embree.cmake index 6d55198ec69..2402b8bfed7 100644 --- a/3rdparty/embree/embree.cmake +++ b/3rdparty/embree/embree.cmake @@ -109,4 +109,4 @@ ExternalProject_Add( ExternalProject_Get_Property(ext_embree INSTALL_DIR) set(EMBREE_INCLUDE_DIRS ${INSTALL_DIR}/include/ ${INSTALL_DIR}/src/ext_embree/) # "/" is critical. set(EMBREE_LIB_DIR ${INSTALL_DIR}/${Open3D_INSTALL_LIB_DIR}) -set(EMBREE_LIBRARIES embree4 simd lexers sys math tasking ${ISA_LIBS}) +set(EMBREE_LIBRARIES embree4 simd lexers sys math tasking ${ISA_LIBS}) \ No newline at end of file diff --git a/3rdparty/filament/filament_build.cmake b/3rdparty/filament/filament_build.cmake index 432f55a28c0..56a7e863956 100644 --- a/3rdparty/filament/filament_build.cmake +++ b/3rdparty/filament/filament_build.cmake @@ -13,20 +13,21 @@ if(NOT is_multi_config) endif() set(filament_LIBRARIES - filameshio - filament - filamat_lite - filamat - filaflat - filabridge - geometry - backend - bluegl - ibl - image - meshoptimizer - smol-v - utils + filameshio + filament + filaflat + filabridge + geometry + backend + bluegl + bluevk + ibl + image + ktxreader + meshoptimizer + smol-v + utils + vkshaders ) # Locate byproducts @@ -43,19 +44,48 @@ set(lib_byproducts ${filament_LIBRARIES}) list(TRANSFORM lib_byproducts PREPEND ${FILAMENT_ROOT}/${lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}) list(TRANSFORM lib_byproducts APPEND ${CMAKE_STATIC_LIBRARY_SUFFIX}) -set(filament_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-deprecated") +set(filament_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-deprecated" "-Wno-pass-failed=transform-warning" "-Wno-error=nonnull") +set(filament_ld_flags "") if(NOT WIN32) # Issue Open3D#1909, filament#2146 set(filament_cxx_flags "${filament_cxx_flags} -fno-builtin") + # Ensure we use the correct LLVM version's shared libc++ (not static libc++ from older LLVM) + # This prevents linker errors with static libc++ that wasn't built with -fPIC + if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + # Find the Clang version to locate the correct libc++ + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} --version + OUTPUT_VARIABLE clang_version_output + ERROR_QUIET + ) + if(clang_version_output MATCHES "clang version ([0-9]+)") + set(CLANG_VER "${CMAKE_MATCH_1}") + set(LLVM_LIBDIR "/usr/lib/llvm-${CLANG_VER}/lib") + set(LLVM_INCDIR "/usr/lib/llvm-${CLANG_VER}/include") + # Use LLVM 14's shared libc++ if available (it's built with -fPIC) + if(EXISTS "${LLVM_LIBDIR}/libc++.so") + set(filament_cxx_flags "${filament_cxx_flags} -L${LLVM_LIBDIR}") + set(filament_ld_flags "-Wl,-rpath,${LLVM_LIBDIR}") + # Force-include cstdint to fix missing uint32_t in Filament headers + # This is a workaround for Filament's TIFFExport.h missing #include + if(EXISTS "${LLVM_INCDIR}/c++/v1/cstdint") + set(filament_cxx_flags "${filament_cxx_flags} -include ${LLVM_INCDIR}/c++/v1/cstdint") + endif() + message(STATUS "Filament: Using LLVM ${CLANG_VER} shared libc++ from ${LLVM_LIBDIR}") + endif() + endif() + endif() endif() ExternalProject_Add( ext_filament PREFIX filament - URL https://github.com/isl-org/filament/archive/d1d873d27f43ba0cee1674a555cc0f18daac3008.tar.gz - URL_HASH SHA256=00c3f41af0fcfb2df904e1f77934f2678d943ddac5eb889788a5e22590e497bd + URL https://github.com/google/filament/archive/refs/tags/v1.58.2.tar.gz + URL_HASH SHA256=8fbb35db77f34138e0c0536866d0de81e49b3ba2a3bd2d75e6de834779515cda DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/filament" UPDATE_COMMAND "" + PATCH_COMMAND + bash -c "sed -i '/^#include /a #include ' libs/viewer/src/TIFFExport.h || true" CMAKE_ARGS ${ExternalProject_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${FILAMENT_BUILD_TYPE} @@ -66,12 +96,14 @@ ExternalProject_Add( -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} -DCMAKE_CXX_FLAGS:STRING=${filament_cxx_flags} + -DCMAKE_EXE_LINKER_FLAGS:STRING=${filament_ld_flags} + -DCMAKE_SHARED_LINKER_FLAGS:STRING=${filament_ld_flags} -DCMAKE_INSTALL_PREFIX=${FILAMENT_ROOT} -DUSE_STATIC_CRT=${STATIC_WINDOWS_RUNTIME} - -DUSE_STATIC_LIBCXX=ON - -DFILAMENT_SUPPORTS_VULKAN=OFF + -DUSE_STATIC_LIBCXX=OFF + -DFILAMENT_SKIP_SDL2=ON -DFILAMENT_SKIP_SAMPLES=ON -DFILAMENT_OPENGL_HANDLE_ARENA_SIZE_IN_MB=20 # to support many small entities -DSPIRV_WERROR=OFF - BUILD_BYPRODUCTS ${lib_byproducts} -) + BUILD_BYPRODUCTS ${lib_byproducts} +) \ No newline at end of file diff --git a/3rdparty/filament/filament_download.cmake b/3rdparty/filament/filament_download.cmake index f21cc91c31b..71249d76e96 100644 --- a/3rdparty/filament/filament_download.cmake +++ b/3rdparty/filament/filament_download.cmake @@ -1,6 +1,7 @@ include(FetchContent) +include(ExternalProject) -set(filament_LIBRARIES filameshio filament filamat_lite filaflat filabridge geometry backend bluegl bluevk ibl image meshoptimizer smol-v utils vkshaders) +set(filament_LIBRARIES filameshio filament filaflat filabridge geometry backend bluegl bluevk ibl image ktxreader meshoptimizer smol-v utils vkshaders) if (FILAMENT_PRECOMPILED_ROOT) if (EXISTS "${FILAMENT_PRECOMPILED_ROOT}") @@ -13,51 +14,25 @@ else() set(lib_dir lib) # Setup download links if(WIN32) - set(FILAMENT_URL https://github.com/google/filament/releases/download/v1.9.9/filament-v1.9.9-windows.tgz) - set(FILAMENT_SHA256 3a937a54a0c6b693c833737878761f8ba8ee02744be3c2f9ec33b1c6399ba31b) - # Required for filament v1.9.9 - # Older versions of filament do not contain vkshaders. - # They also have a different directory structure. - # Remove vkshaders here so we can use newer versions with FILAMENT_PRECOMPILED_ROOT. - list(REMOVE_ITEM filament_LIBRARIES vkshaders) + set(FILAMENT_URL https://github.com/google/filament/releases/download/v1.58.2/filament-windows.tgz) + set(FILAMENT_SHA256 8b07ea0f234a3eececed8e9fda9742de48ab04260aab2aa472d70242d790c8db) if (STATIC_WINDOWS_RUNTIME) string(APPEND lib_dir /x86_64/mt) else() string(APPEND lib_dir /x86_64/md) endif() elseif(APPLE) - if (APPLE_AARCH64) - set(FILAMENT_URL https://github.com/isl-org/open3d_downloads/releases/download/filament/filament-v1.9.19-macos_arm64.tgz) - set(FILAMENT_SHA256 3422bdff451d90144fbb69e625d8dcaeaf3222dc2c28879536067937955bc362) - string(APPEND lib_dir /arm64) - # Our arm64 builds use FILAMENT_SUPPORTS_VULKAN=OFF - list(REMOVE_ITEM filament_LIBRARIES bluevk) - else() - set(FILAMENT_URL https://github.com/google/filament/releases/download/v1.9.19/filament-v1.9.19-mac.tgz) - set(FILAMENT_SHA256 2765d0ce60647fc17d1880c4618cf7d6b5343d8be4dad87978c3917d9c723b4e) - string(APPEND lib_dir /x86_64) - endif() - else() # Linux: Check glibc version and use open3d filament binary if new (Ubuntu 20.04 and similar) - execute_process(COMMAND ldd --version OUTPUT_VARIABLE ldd_version) - string(REGEX MATCH "([0-9]+\.)+[0-9]+" glibc_version ${ldd_version}) - if(${glibc_version} VERSION_LESS "2.31") - set(FILAMENT_URL - https://github.com/isl-org/open3d_downloads/releases/download/filament/filament-v1.9.19-linux.tgz) - set(FILAMENT_SHA256 f0c0b05a543dd0c82b1cd571957a90f28e72cfeee36d19a527c17ac9de4733d5) - message(STATUS "GLIBC version ${glibc_version} found: Using " - "Google Filament binary.") - else() - set(FILAMENT_URL - https://github.com/isl-org/open3d_downloads/releases/download/filament/filament-v1.9.19-linux-20.04.tgz) - set(FILAMENT_SHA256 c756fd76f5c6a40ca554f8c3cca424354a2a22ea6fce3c8ea893d4c4aa39514c) - message(STATUS "GLIBC version ${glibc_version} found: Using " - "Open3D Filament binary.") - endif() + set(FILAMENT_URL https://github.com/google/filament/releases/download/v1.58.2/filament-v1.58.2-mac.tgz) + set(FILAMENT_SHA256 d0fceb641295756fa674520c9ebf19f8929278b5fc550e5abbf50c3094e6922a) + else() + set(FILAMENT_URL https://github.com/google/filament/releases/download/v1.58.2/filament-v1.58.2-linux.tgz) + set(FILAMENT_SHA256 9c4c715402f0cb675660c34f2fdf3d00f12b198b42bfbf0765a3ec40f33c84cc) endif() set(lib_byproducts ${filament_LIBRARIES}) list(TRANSFORM lib_byproducts PREPEND /${lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}) list(TRANSFORM lib_byproducts APPEND ${CMAKE_STATIC_LIBRARY_SUFFIX}) + message(STATUS "Filament byproducts: ${lib_byproducts}") if(WIN32) set(lib_byproducts_debug ${filament_LIBRARIES}) @@ -68,20 +43,135 @@ else() # ExternalProject_Add happens at build time. ExternalProject_Add( - ext_filament - PREFIX filament - URL ${FILAMENT_URL} - URL_HASH SHA256=${FILAMENT_SHA256} - DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/filament" - UPDATE_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_IN_SOURCE ON - BUILD_COMMAND "" - INSTALL_COMMAND "" - BUILD_BYPRODUCTS ${lib_byproducts} + ext_filament + PREFIX filament + URL ${FILAMENT_URL} + URL_HASH SHA256=${FILAMENT_SHA256} + DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/filament" + UPDATE_COMMAND "" + CONFIGURE_COMMAND "" + BUILD_IN_SOURCE ON + BUILD_COMMAND "" + INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${lib_byproducts} ) ExternalProject_Get_Property(ext_filament SOURCE_DIR) + message(STATUS "Filament source dir is ${SOURCE_DIR}") set(FILAMENT_ROOT ${SOURCE_DIR}) + + # On Linux, build matc from source to avoid GLIBC version issues + if(UNIX AND NOT APPLE) + message(STATUS "Building matc from source to ensure GLIBC compatibility") + + # Determine compiler for matc (Filament requires Clang >= 7) + set(MATC_C_COMPILER "${CMAKE_C_COMPILER}") + set(MATC_CXX_COMPILER "${CMAKE_CXX_COMPILER}") + + if(NOT MSVC AND NOT (CMAKE_C_COMPILER_ID MATCHES ".*Clang" AND + CMAKE_CXX_COMPILER_ID MATCHES ".*Clang" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)) + # Try to find a suitable Clang version + find_program(CLANG_VERSIONED_CXX NAMES + clang++-19 clang++-18 clang++-17 clang++-16 clang++-15 + clang++-14 clang++-13 clang++-12 clang++-11 clang++-10 + clang++-9 clang++-8 clang++-7 + ) + if(CLANG_VERSIONED_CXX) + get_filename_component(CLANG_VERSIONED_CXX_NAME "${CLANG_VERSIONED_CXX}" NAME_WE) + string(REPLACE "++" "" CLANG_VERSIONED_CC_NAME "${CLANG_VERSIONED_CXX_NAME}") + get_filename_component(CLANG_VERSIONED_CXX_DIR "${CLANG_VERSIONED_CXX}" DIRECTORY) + find_program(CLANG_VERSIONED_CC_FULL + NAMES ${CLANG_VERSIONED_CC_NAME} + PATHS ${CLANG_VERSIONED_CXX_DIR} + NO_DEFAULT_PATH + ) + if(CLANG_VERSIONED_CC_FULL) + set(MATC_C_COMPILER "${CLANG_VERSIONED_CC_FULL}") + set(MATC_CXX_COMPILER "${CLANG_VERSIONED_CXX}") + message(STATUS "Found Clang for matc: ${MATC_CXX_COMPILER}") + endif() + endif() + + # Fallback to default clang++ + if(NOT MATC_CXX_COMPILER OR MATC_CXX_COMPILER STREQUAL CMAKE_CXX_COMPILER) + find_program(CLANG_DEFAULT_CXX NAMES clang++) + if(CLANG_DEFAULT_CXX) + execute_process(COMMAND ${CLANG_DEFAULT_CXX} --version OUTPUT_VARIABLE clang_version ERROR_QUIET) + if(clang_version MATCHES "clang version ([0-9]+)") + if (CMAKE_MATCH_1 GREATER_EQUAL 7) + get_filename_component(CLANG_DEFAULT_CXX_DIR "${CLANG_DEFAULT_CXX}" DIRECTORY) + find_program(CLANG_DEFAULT_CC_FULL NAMES clang PATHS ${CLANG_DEFAULT_CXX_DIR} NO_DEFAULT_PATH) + if(CLANG_DEFAULT_CC_FULL) + set(MATC_C_COMPILER "${CLANG_DEFAULT_CC_FULL}") + set(MATC_CXX_COMPILER "${CLANG_DEFAULT_CXX}") + message(STATUS "Found default Clang for matc: ${MATC_CXX_COMPILER}") + endif() + endif() + endif() + endif() + endif() + endif() + + set(filament_cxx_flags "${CMAKE_CXX_FLAGS} -Wno-deprecated" "-Wno-pass-failed=transform-warning" "-Wno-error=nonnull") + if(NOT WIN32) + set(filament_cxx_flags "${filament_cxx_flags} -fno-builtin") + endif() + + # Build matc from source + ExternalProject_Add( + ext_filament_matc + PREFIX filament-matc + URL https://github.com/google/filament/archive/refs/tags/v1.58.2.tar.gz + URL_HASH SHA256=8fbb35db77f34138e0c0536866d0de81e49b3ba2a3bd2d75e6de834779515cda + DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/filament" + UPDATE_COMMAND "" + CMAKE_ARGS + ${ExternalProject_CMAKE_ARGS} + -DCMAKE_BUILD_TYPE=Release + -DCCACHE_PROGRAM=OFF + -DFILAMENT_ENABLE_JAVA=OFF + -DCMAKE_C_COMPILER=${MATC_C_COMPILER} + -DCMAKE_CXX_COMPILER=${MATC_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${filament_cxx_flags} + -DCMAKE_INSTALL_PREFIX= + -DUSE_STATIC_CRT=${STATIC_WINDOWS_RUNTIME} + -DUSE_STATIC_LIBCXX=ON + -DFILAMENT_SKIP_SDL2=ON + -DFILAMENT_SKIP_SAMPLES=ON + -DFILAMENT_BUILD_FILAMAT=ON + -DFILAMENT_BUILD_FILABRIDGE=ON + -DFILAMENT_BUILD_IMAGE=ON + -DFILAMENT_BUILD_UTILS=ON + -DFILAMENT_BUILD_TOOLS=ON + -DFILAMENT_BUILD_FILAMENT=OFF + -DFILAMENT_BUILD_GEOMETRY=OFF + -DFILAMENT_BUILD_BACKEND=OFF + -DFILAMENT_BUILD_GLSLANG=OFF + -DFILAMENT_BUILD_SPIRV_TOOLS=OFF + -DFILAMENT_BUILD_VALIDATOR=OFF + -DFILAMENT_BUILD_SHADERS=OFF + -DFILAMENT_BUILD_CMGEN=OFF + -DFILAMENT_BUILD_FILAMESH=OFF + -DFILAMENT_BUILD_FILAMESHIO=OFF + -DFILAMENT_BUILD_KTXREADER=OFF + -DFILAMENT_BUILD_MESHOPTIMIZER=OFF + -DFILAMENT_BUILD_SMOLV=OFF + -DFILAMENT_BUILD_VKSHADERS=OFF + -DFILAMENT_BUILD_IBL=OFF + -DFILAMENT_BUILD_BLUEGL=OFF + -DFILAMENT_BUILD_BLUEVK=OFF + -DSPIRV_WERROR=OFF + BUILD_COMMAND ${CMAKE_COMMAND} --build . --target matc --config Release + INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping install" + BUILD_BYPRODUCTS + /tools/matc/matc${CMAKE_EXECUTABLE_SUFFIX} + DEPENDS ext_filament + ) + + ExternalProject_Get_Property(ext_filament_matc BINARY_DIR) + set(FILAMENT_MATC_BUILT "${BINARY_DIR}/tools/matc/matc${CMAKE_EXECUTABLE_SUFFIX}") + message(STATUS "matc will be built at: ${FILAMENT_MATC_BUILT}") + endif() endif() -message(STATUS "Filament is located at ${FILAMENT_ROOT}") +message(STATUS "Filament is located at ${FILAMENT_ROOT}") \ No newline at end of file diff --git a/3rdparty/find_dependencies.cmake b/3rdparty/find_dependencies.cmake index c9bf95c98de..5def698432c 100644 --- a/3rdparty/find_dependencies.cmake +++ b/3rdparty/find_dependencies.cmake @@ -1316,22 +1316,25 @@ if(BUILD_GUI) else() message(STATUS "Using prebuilt third-party library Filament") include(${Open3D_3RDPARTY_DIR}/filament/filament_download.cmake) - # Set lib directory for filament v1.9.9 on Windows. - # Assume newer version if FILAMENT_PRECOMPILED_ROOT is set. - if (WIN32 AND NOT FILAMENT_PRECOMPILED_ROOT) - if (STATIC_WINDOWS_RUNTIME) - set(FILAMENT_RUNTIME_VER "x86_64/mt$<$:d>") - else() - set(FILAMENT_RUNTIME_VER "x86_64/md$<$:d>") - endif() - endif() endif() - if (APPLE) + if (UNIX AND NOT APPLE) + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)$") + set(FILAMENT_RUNTIME_VER aarch64) + else() + set(FILAMENT_RUNTIME_VER x86_64) + endif() + elseif (APPLE) if (APPLE_AARCH64) set(FILAMENT_RUNTIME_VER arm64) else() set(FILAMENT_RUNTIME_VER x86_64) endif() + else() # WIN32 + if (STATIC_WINDOWS_RUNTIME) + set(FILAMENT_RUNTIME_VER "x86_64/mt$<$:d>") + else() + set(FILAMENT_RUNTIME_VER "x86_64/md$<$:d>") + endif() endif() open3d_import_3rdparty_library(3rdparty_filament HEADER @@ -1340,7 +1343,15 @@ if(BUILD_GUI) LIBRARIES ${filament_LIBRARIES} DEPENDS ext_filament ) - set(FILAMENT_MATC "${FILAMENT_ROOT}/bin/matc") + # Use built matc if available (for Linux GLIBC compatibility), otherwise use pre-compiled + if(UNIX AND NOT APPLE AND NOT BUILD_FILAMENT_FROM_SOURCE AND DEFINED FILAMENT_MATC_BUILT) + set(FILAMENT_MATC "${FILAMENT_MATC_BUILT}") + if(TARGET ext_filament_matc) + add_dependencies(3rdparty_filament ext_filament_matc) + endif() + else() + set(FILAMENT_MATC "${FILAMENT_ROOT}/bin/matc") + endif() target_link_libraries(3rdparty_filament INTERFACE Open3D::3rdparty_threads ${CMAKE_DL_LIBS}) if(UNIX AND NOT APPLE) # For ubuntu, llvm libs are located in /usr/lib/llvm-{version}/lib. diff --git a/3rdparty/openblas/openblas.cmake b/3rdparty/openblas/openblas.cmake index 1c97dbd8429..87220ba5086 100644 --- a/3rdparty/openblas/openblas.cmake +++ b/3rdparty/openblas/openblas.cmake @@ -9,8 +9,8 @@ endif() ExternalProject_Add( ext_openblas PREFIX openblas - URL https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.29/OpenBLAS-0.3.29.tar.gz - URL_HASH SHA256=38240eee1b29e2bde47ebb5d61160207dc68668a54cac62c076bb5032013b1eb + URL https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.30/OpenBLAS-0.3.30.tar.gz + URL_HASH SHA256=27342cff518646afb4c2b976d809102e368957974c250a25ccc965e53063c95d DOWNLOAD_DIR "${OPEN3D_THIRD_PARTY_DOWNLOAD_DIR}/openblas" CMAKE_ARGS ${ExternalProject_CMAKE_ARGS} diff --git a/CMakeLists.txt b/CMakeLists.txt index 74e97b5a922..0be6c5617fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ if(UNIX AND NOT APPLE) ) if(PROCESSOR_ARCH STREQUAL "aarch64") set(LINUX_AARCH64 TRUE) + elseif(PROCESSOR_ARCH STREQUAL "x86_64") + set(LINUX_X86_64 TRUE) endif() endif() if(APPLE) @@ -126,13 +128,19 @@ option(USE_SYSTEM_ZEROMQ "Use system pre-installed ZeroMQ" OFF if(LINUX_AARCH64 OR APPLE_AARCH64) option(BUILD_VTK_FROM_SOURCE "Build VTK from source" ON ) else() - option(BUILD_VTK_FROM_SOURCE "Build VTK from source" OFF) + option(BUILD_VTK_FROM_SOURCE "Build VTK from source" OFF) + endif() +if(LINUX_AARCH64 OR APPLE_AARCH64) + option(BUILD_VTK_FROM_SOURCE "Build VTK from source" ON ) + else() + option(BUILD_VTK_FROM_SOURCE "Build VTK from source" OFF) + endif() + +if(LINUX_AARCH64 OR LINUX_X86_64) + option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" ON ) + else() + option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" OFF) endif() -if(LINUX_AARCH64) - option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" ON ) -else() - option(BUILD_FILAMENT_FROM_SOURCE "Build filament from source" OFF) -endif() option(PREFER_OSX_HOMEBREW "Prefer Homebrew libs over frameworks" ON ) option(WITH_MINIZIP "Enable MiniZIP" OFF) @@ -602,4 +610,4 @@ add_custom_target(apply-cpp-style ) include(Open3DPrintConfigurationSummary) -open3d_print_configuration_summary() +open3d_print_configuration_summary() \ No newline at end of file diff --git a/cmake/Open3DAddCompiledMaterials.cmake b/cmake/Open3DAddCompiledMaterials.cmake index 171e57e6376..fa91e82fee2 100644 --- a/cmake/Open3DAddCompiledMaterials.cmake +++ b/cmake/Open3DAddCompiledMaterials.cmake @@ -35,12 +35,18 @@ function(open3d_add_compiled_materials target) if (IOS OR ANDROID) set(FILAMENT_MATC_ARGS "--platform=mobile") else() - set(FILAMENT_MATC_ARGS "--platform=desktop") + set(FILAMENT_MATC_ARGS "--api=all") endif() get_filename_component(OUTPUT_DIRECTORY_FULL_PATH "${ARG_OUTPUT_DIRECTORY}" ABSOLUTE) # Build compiled materials + # Determine dependencies - include matc build target if it exists + set(material_depends Open3D::3rdparty_filament) + if(TARGET ext_filament_matc) + list(APPEND material_depends ext_filament_matc) + endif() + foreach (mat IN LISTS ARG_SOURCES) get_filename_component(MATERIAL_FULL_PATH "${mat}" ABSOLUTE) @@ -53,7 +59,7 @@ function(open3d_add_compiled_materials target) OUTPUT ${COMPILED_MATERIAL_FULL_PATH} COMMAND ${FILAMENT_MATC} ${FILAMENT_MATC_ARGS} -o ${COMPILED_MATERIAL_FULL_PATH} ${MATERIAL_FULL_PATH} COMMENT "Building Material object ${COMPILED_MATERIAL_RELATIVE_PATH}" - MAIN_DEPENDENCY ${mat} DEPENDS Open3D::3rdparty_filament + MAIN_DEPENDENCY ${mat} DEPENDS ${material_depends} VERBATIM ) diff --git a/cpp/open3d/geometry/TriangleMesh.cpp b/cpp/open3d/geometry/TriangleMesh.cpp index bb5f9571e09..c5f122a376b 100644 --- a/cpp/open3d/geometry/TriangleMesh.cpp +++ b/cpp/open3d/geometry/TriangleMesh.cpp @@ -293,6 +293,16 @@ std::shared_ptr TriangleMesh::FilterSmoothSimple( std::swap(mesh->vertex_colors_, prev_vertex_colors); } } + if (filter_vertex) { + const double epsilon = 1e-15; + for (auto &vertex : mesh->vertices_) { + for (int i = 0; i < 3; ++i) { + if (std::abs(vertex(i)) < epsilon) { + vertex(i) = 0.0; + } + } + } + } return mesh; } @@ -386,6 +396,16 @@ std::shared_ptr TriangleMesh::FilterSmoothLaplacian( std::swap(mesh->vertex_colors_, prev_vertex_colors); } } + if (filter_vertex) { + const double epsilon = 1e-15; + for (auto &vertex : mesh->vertices_) { + for (int i = 0; i < 3; ++i) { + if (std::abs(vertex(i)) < epsilon) { + vertex(i) = 0.0; + } + } + } + } return mesh; } @@ -434,6 +454,16 @@ std::shared_ptr TriangleMesh::FilterSmoothTaubin( std::swap(mesh->vertex_colors_, prev_vertex_colors); } } + if (filter_vertex) { + const double epsilon = 1e-15; + for (auto &vertex : mesh->vertices_) { + for (int i = 0; i < 3; ++i) { + if (std::abs(vertex(i)) < epsilon) { + vertex(i) = 0.0; + } + } + } + } return mesh; } diff --git a/cpp/open3d/visualization/CMakeLists.txt b/cpp/open3d/visualization/CMakeLists.txt index 833ca2ae40f..4bc450421eb 100644 --- a/cpp/open3d/visualization/CMakeLists.txt +++ b/cpp/open3d/visualization/CMakeLists.txt @@ -2,6 +2,14 @@ open3d_ispc_add_library(visualization OBJECT) open3d_ispc_add_library(visualization_impl OBJECT) set_target_properties(visualization_impl PROPERTIES CXX_VISIBILITY_PRESET hidden) +# filament uses C++20 designated initializers +set_property(TARGET visualization_impl visualization PROPERTY CXX_STANDARD 20) + +# Workaround for Filament header naming conflict with GCC +# MaterialInstance.h has a using declaration that conflicts with enum class TransparencyMode +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(visualization_impl PRIVATE -fpermissive) +endif() target_sources(visualization_impl PRIVATE shader/GeometryRenderer.cpp diff --git a/cpp/open3d/visualization/gui/Application.cpp b/cpp/open3d/visualization/gui/Application.cpp index 85b260a0182..8f2630b9973 100644 --- a/cpp/open3d/visualization/gui/Application.cpp +++ b/cpp/open3d/visualization/gui/Application.cpp @@ -148,9 +148,9 @@ struct Application::Impl { InitWindowSystem(); // Initialize rendering - visualization::rendering::EngineInstance::SelectBackend( - visualization::rendering::EngineInstance::RenderingType:: - kOpenGL); + // NOTE: This is where we used to manually select a backend for Filament + // but we feel comfortable now allowing Filament to select the best + // backend for the platform so there's no code here anymore } void CleanupAfterRunning() { diff --git a/cpp/open3d/visualization/gui/BitmapWindowSystem.cpp b/cpp/open3d/visualization/gui/BitmapWindowSystem.cpp index f40e5545556..dc5cc6dd985 100644 --- a/cpp/open3d/visualization/gui/BitmapWindowSystem.cpp +++ b/cpp/open3d/visualization/gui/BitmapWindowSystem.cpp @@ -128,17 +128,8 @@ struct BitmapWindowSystem::Impl { BitmapEventQueue event_queue_; }; -BitmapWindowSystem::BitmapWindowSystem(Rendering mode /*= Rendering::NORMAL*/) - : impl_(new BitmapWindowSystem::Impl()) { - if (mode == Rendering::HEADLESS) { -#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_WIN64) - rendering::EngineInstance::EnableHeadless(); -#else - utility::LogWarning( - "BitmapWindowSystem(): HEADLESS is only supported on Linux."); -#endif - } -} +BitmapWindowSystem::BitmapWindowSystem() + : impl_(new BitmapWindowSystem::Impl()) {} BitmapWindowSystem::~BitmapWindowSystem() {} diff --git a/cpp/open3d/visualization/gui/BitmapWindowSystem.h b/cpp/open3d/visualization/gui/BitmapWindowSystem.h index a0558c6898b..d80724fee6f 100644 --- a/cpp/open3d/visualization/gui/BitmapWindowSystem.h +++ b/cpp/open3d/visualization/gui/BitmapWindowSystem.h @@ -27,12 +27,14 @@ struct TextInputEvent; class BitmapWindowSystem : public WindowSystem { public: - enum class Rendering { - NORMAL, // normal OpenGL rendering, requires X11, Win32, or Cocoa - HEADLESS // uses EGL, does not require the OS to have a window system. - // (Linux only) - }; - BitmapWindowSystem(Rendering mode = Rendering::NORMAL); + // Not needed anymore - may be removed (kept as reference) + // enum class Rendering { + // NORMAL, // normal OpenGL rendering, requires X11, Win32, or Cocoa + // HEADLESS // uses EGL, does not require the OS to have a window + // system. + // // (Linux only) + // }; + BitmapWindowSystem(); ~BitmapWindowSystem(); void Initialize() override; diff --git a/cpp/open3d/visualization/gui/CMakeLists.txt b/cpp/open3d/visualization/gui/CMakeLists.txt index 822de19a93b..739b941f641 100644 --- a/cpp/open3d/visualization/gui/CMakeLists.txt +++ b/cpp/open3d/visualization/gui/CMakeLists.txt @@ -59,6 +59,14 @@ else() NativeLinux.cpp ) endif() +# filament uses C++20 designated initializers +set_property(TARGET GUI PROPERTY CXX_STANDARD 20) + +# Workaround for Filament header naming conflict with GCC +# MaterialInstance.h has a using declaration that conflicts with enum class TransparencyMode +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(GUI PRIVATE -fpermissive) +endif() open3d_show_and_abort_on_warning(GUI) open3d_set_global_properties(GUI) diff --git a/cpp/open3d/visualization/gui/GLFWWindowSystem.cpp b/cpp/open3d/visualization/gui/GLFWWindowSystem.cpp index 852f6e3db24..c4dc52163a8 100644 --- a/cpp/open3d/visualization/gui/GLFWWindowSystem.cpp +++ b/cpp/open3d/visualization/gui/GLFWWindowSystem.cpp @@ -150,16 +150,18 @@ GLFWWindowSystem::OSWindow GLFWWindowSystem::CreateOSWindow(Window* o3d_window, int height, const char* title, int flags) { - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - // NOTE: Setting alpha and stencil bits to match GLX standard default - // values. GLFW sets these internally to 8 and 8 respectively if not - // specified which causes problems with Filament on Linux with Nvidia binary - // driver - glfwWindowHint(GLFW_ALPHA_BITS, 0); - glfwWindowHint(GLFW_STENCIL_BITS, 0); + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + // glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + // glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + // // NOTE: Setting alpha and stencil bits to match GLX standard default + // // values. GLFW sets these internally to 8 and 8 respectively if not + // // specified which causes problems with Filament on Linux with Nvidia + // binary + // // driver + // glfwWindowHint(GLFW_ALPHA_BITS, 0); + // glfwWindowHint(GLFW_STENCIL_BITS, 0); #if __APPLE__ glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE); diff --git a/cpp/open3d/visualization/gui/ImguiFilamentBridge.cpp b/cpp/open3d/visualization/gui/ImguiFilamentBridge.cpp index 73d773b2cb7..f7c7ade055c 100644 --- a/cpp/open3d/visualization/gui/ImguiFilamentBridge.cpp +++ b/cpp/open3d/visualization/gui/ImguiFilamentBridge.cpp @@ -22,6 +22,11 @@ * limitations under the License. */ +// clang-format off +// NOTE: this must precede header files that bring in Filament headers +#include +// clang-format on + #include "open3d/visualization/gui/ImguiFilamentBridge.h" // 4068: Filament has some clang-specific vectorizing pragma's that MSVC flags @@ -38,6 +43,11 @@ #include #include +#include +#include +#include +#include + #ifdef _MSC_VER #pragma warning(pop) #endif // _MSC_VER @@ -45,11 +55,6 @@ #include #include -#include -#include -#include -#include - #include "open3d/utility/FileSystem.h" #include "open3d/visualization/gui/Application.h" #include "open3d/visualization/gui/Color.h" diff --git a/cpp/open3d/visualization/gui/Materials/img_blit.mat b/cpp/open3d/visualization/gui/Materials/img_blit.mat index d112a184bde..341a5398554 100644 --- a/cpp/open3d/visualization/gui/Materials/img_blit.mat +++ b/cpp/open3d/visualization/gui/Materials/img_blit.mat @@ -20,7 +20,6 @@ fragment { void material(inout MaterialInputs material) { prepareMaterial(material); vec2 uv = getUV0(); - uv.y = 1.0 - uv.y; /* OpenGL spec 8.4.4.4 says that texture().a is 1.0 if there is no alpha channel, so this shader can handle both RGB and RGBA images */ diff --git a/cpp/open3d/visualization/gui/SceneWidget.cpp b/cpp/open3d/visualization/gui/SceneWidget.cpp index d0df7af860e..3f116de3c70 100644 --- a/cpp/open3d/visualization/gui/SceneWidget.cpp +++ b/cpp/open3d/visualization/gui/SceneWidget.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/cpp/open3d/visualization/rendering/RendererHandle.h b/cpp/open3d/visualization/rendering/RendererHandle.h index e65992e7459..321e37a68bf 100644 --- a/cpp/open3d/visualization/rendering/RendererHandle.h +++ b/cpp/open3d/visualization/rendering/RendererHandle.h @@ -165,10 +165,10 @@ struct formatter< template auto format(const open3d::visualization::rendering::REHandle_abstract& uid, FormatContext& ctx) const -> decltype(ctx.out()) { - return format_to(ctx.out(), "[{}, {}, hash: {}]", - open3d::visualization::rendering::REHandle_abstract:: - TypeToString(uid.type), - uid.GetId(), uid.Hash()); + return fmt::format_to(ctx.out(), "[{}, {}, hash: {}]", + open3d::visualization::rendering:: + REHandle_abstract::TypeToString(uid.type), + uid.GetId(), uid.Hash()); } template diff --git a/cpp/open3d/visualization/rendering/filament/FilamentCamera.cpp b/cpp/open3d/visualization/rendering/filament/FilamentCamera.cpp index e7a1580c4e9..1e3a0c43c6c 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentCamera.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentCamera.cpp @@ -40,15 +40,21 @@ Camera::Transform FilamentToCameraTransform(const filament::math::mat4& ft) { return Camera::Transform(m); } -Camera::Transform FilamentToCameraTransform(const filament::math::mat4f& ft) { - Camera::Transform::MatrixType m; - - m << ft(0, 0), ft(0, 1), ft(0, 2), ft(0, 3), ft(1, 0), ft(1, 1), ft(1, 2), - ft(1, 3), ft(2, 0), ft(2, 1), ft(2, 2), ft(2, 3), ft(3, 0), - ft(3, 1), ft(3, 2), ft(3, 3); - - return Camera::Transform(m); -} +// This mat4f overload is not needed because Filament's Camera API methods +// (getModelMatrix(), getViewMatrix(), getCullingProjectionMatrix()) return +// mat4 (double precision), not mat4f (float precision). The mat4 overload +// above handles all current use cases. +// Camera::Transform FilamentToCameraTransform(const filament::math::mat4f& ft) +// { +// Camera::Transform::MatrixType m; +// +// m << ft(0, 0), ft(0, 1), ft(0, 2), ft(0, 3), ft(1, 0), ft(1, 1), ft(1, +// 2), +// ft(1, 3), ft(2, 0), ft(2, 1), ft(2, 2), ft(2, 3), ft(3, 0), +// ft(3, 1), ft(3, 2), ft(3, 3); +// +// return Camera::Transform(m); +// } filament::math::mat4f CameraToFilamentTransformF(const Camera::Transform& t) { auto e_matrix = t.matrix(); @@ -240,7 +246,8 @@ void FilamentCamera::LookAt(const Eigen::Vector3f& center, Eigen::Vector3f FilamentCamera::GetPosition() const { auto cam_pos = camera_->getPosition(); - return {cam_pos.x, cam_pos.y, cam_pos.z}; + return {static_cast(cam_pos.x), static_cast(cam_pos.y), + static_cast(cam_pos.z)}; } Eigen::Vector3f FilamentCamera::GetForwardVector() const { @@ -314,7 +321,7 @@ void FilamentCamera::SetModelMatrix(const Eigen::Vector3f& forward, const Eigen::Vector3f& up) { using namespace filament; - math::mat4f ftransform = camera_->getModelMatrix(); + math::mat4 ftransform = camera_->getModelMatrix(); ftransform[0].xyz = math::float3(left.x(), left.y(), left.z()); ftransform[1].xyz = math::float3(up.x(), up.y(), up.z()); ftransform[2].xyz = math::float3(forward.x(), forward.y(), forward.z()); diff --git a/cpp/open3d/visualization/rendering/filament/FilamentEngine.cpp b/cpp/open3d/visualization/rendering/filament/FilamentEngine.cpp index f90b00d5a03..85ffba2c555 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentEngine.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentEngine.cpp @@ -33,13 +33,10 @@ static std::shared_ptr g_instance = nullptr; } // namespace EngineInstance::RenderingType EngineInstance::type_ = RenderingType::kDefault; -bool EngineInstance::is_headless_ = false; std::string EngineInstance::resource_path_ = ""; void EngineInstance::SelectBackend(RenderingType type) { type_ = type; } -void EngineInstance::EnableHeadless() { is_headless_ = true; } - void EngineInstance::SetResourcePath(const std::string& resource_path) { resource_path_ = resource_path; if (!utility::filesystem::DirectoryExists(resource_path_)) { @@ -74,10 +71,6 @@ EngineInstance& EngineInstance::Get() { void EngineInstance::DestroyInstance() { g_instance.reset(); } -/// external function defined in custom Filament EGL backend for headless -/// rendering -extern "C" filament::backend::Platform* CreateEGLHeadlessPlatform(); - EngineInstance::EngineInstance() { filament::backend::Backend backend = filament::backend::Backend::DEFAULT; switch (type_) { @@ -95,17 +88,7 @@ EngineInstance::EngineInstance() { break; } - filament::backend::Platform* custom_platform = nullptr; - if (is_headless_) { -#ifdef __linux__ - utility::LogInfo("EGL headless mode enabled."); - custom_platform = CreateEGLHeadlessPlatform(); -#else - utility::LogError("EGL Headless is not supported on this platform."); -#endif - } - - engine_ = filament::Engine::create(backend, custom_platform); + engine_ = filament::Engine::create(backend); resource_manager_ = new FilamentResourceManager(*engine_); } diff --git a/cpp/open3d/visualization/rendering/filament/FilamentEngine.h b/cpp/open3d/visualization/rendering/filament/FilamentEngine.h index f270279ff97..7b4e6c64963 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentEngine.h +++ b/cpp/open3d/visualization/rendering/filament/FilamentEngine.h @@ -28,10 +28,6 @@ class EngineInstance { // If not called, platform available default backend will be used. static void SelectBackend(RenderingType type); - /// Initialize Engine for headless rendering. Must be called before first - /// access to the Engine (GetInstance). - static void EnableHeadless(); - // Specifies path to load shaders and skyboxes from. Must be called before // instance usage, or default path will be used. static void SetResourcePath(const std::string& resource_path); @@ -53,7 +49,6 @@ class EngineInstance { EngineInstance(); static RenderingType type_; - static bool is_headless_; static std::string resource_path_; filament::Engine* engine_; FilamentResourceManager* resource_manager_; diff --git a/cpp/open3d/visualization/rendering/filament/FilamentGeometryBuffersBuilder.h b/cpp/open3d/visualization/rendering/filament/FilamentGeometryBuffersBuilder.h index 40bbd32d349..34cbc09133a 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentGeometryBuffersBuilder.h +++ b/cpp/open3d/visualization/rendering/filament/FilamentGeometryBuffersBuilder.h @@ -26,9 +26,11 @@ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4068 4146 4293) -// Filament uses OPAQUE and TRANSPARENT as enums which conflicts with windows.h +// Filament uses these as enums / local variables that conflict with windows.h #undef OPAQUE #undef TRANSPARENT +#undef near +#undef far #endif // _MSC_VER #include diff --git a/cpp/open3d/visualization/rendering/filament/FilamentRenderToBuffer.cpp b/cpp/open3d/visualization/rendering/filament/FilamentRenderToBuffer.cpp index 27e758deddb..0a51abf9805 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentRenderToBuffer.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentRenderToBuffer.cpp @@ -32,6 +32,8 @@ #pragma warning(pop) #endif // _MSC_VER +#include + #include "open3d/utility/Logging.h" #include "open3d/visualization/rendering/filament/FilamentEngine.h" #include "open3d/visualization/rendering/filament/FilamentRenderer.h" @@ -162,6 +164,35 @@ void FilamentRenderToBuffer::ReadPixelsCallback(void*, size_t, void* user) { BufferReadyCallback callback; std::tie(self, callback) = *params; + // Filament's readPixels returns data with Y=0 at bottom (OpenGL + // convention), but most image formats and display systems expect Y=0 at + // top. Flip the Y-axis to match the behavior of Open3DViewer + // (VisualizerRender). + if (self->buffer_ && self->width_ > 0 && self->height_ > 0) { + const std::size_t bytes_per_pixel = + self->depth_image_ ? sizeof(std::float_t) + : self->n_channels_ * sizeof(std::uint8_t); + const std::size_t bytes_per_line = self->width_ * bytes_per_pixel; + const std::size_t total_bytes = bytes_per_line * self->height_; + + // Allocate temporary buffer for flipped data + std::uint8_t* flipped_buffer = + static_cast(malloc(total_bytes)); + if (flipped_buffer) { + // Copy rows in reverse order + for (std::size_t i = 0; i < self->height_; i++) { + std::size_t src_row = self->height_ - i - 1; + std::memcpy(flipped_buffer + bytes_per_line * i, + self->buffer_ + bytes_per_line * src_row, + bytes_per_line); + } + + // Replace buffer with flipped data + std::memcpy(self->buffer_, flipped_buffer, total_bytes); + free(flipped_buffer); + } + } + callback({self->width_, self->height_, self->n_channels_, self->buffer_, self->buffer_size_}); diff --git a/cpp/open3d/visualization/rendering/filament/FilamentResourceManager.cpp b/cpp/open3d/visualization/rendering/filament/FilamentResourceManager.cpp index dd10e441f59..b21d1b91d68 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentResourceManager.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentResourceManager.cpp @@ -33,8 +33,7 @@ #include #include #include -#include -#include +#include #ifdef _MSC_VER #pragma warning(pop) @@ -596,8 +595,10 @@ RenderTargetHandle FilamentResourceManager::CreateRenderTarget( } auto rt = RenderTarget::Builder() - .texture(RenderTarget::COLOR, color_tex.get()) - .texture(RenderTarget::DEPTH, depth_tex.get()) + .texture(RenderTarget::AttachmentPoint::COLOR, + color_tex.get()) + .texture(RenderTarget::AttachmentPoint::DEPTH, + depth_tex.get()) .build(engine_); handle = RegisterResource(engine_, rt, render_targets_); return handle; @@ -615,11 +616,11 @@ IndirectLightHandle FilamentResourceManager::CreateIndirectLight( &error_str)) { using namespace filament; // will be destroyed later by image::ktx::createTexture - auto* ibl_ktx = new image::KtxBundle( + auto* ibl_ktx = new image::Ktx1Bundle( reinterpret_cast(ibl_data.data()), std::uint32_t(ibl_data.size())); - auto* ibl_texture = - image::ktx::createTexture(&engine_, ibl_ktx, false); + auto* ibl_texture = ktxreader::Ktx1Reader::createTexture( + &engine_, ibl_ktx, false); filament::math::float3 bands[9] = {}; if (!ibl_ktx->getSphericalHarmonics(bands)) { @@ -684,11 +685,11 @@ SkyboxHandle FilamentResourceManager::CreateSkybox( &error_str)) { using namespace filament; // will be destroyed later by image::ktx::createTexture - auto* sky_ktx = new image::KtxBundle( + auto* sky_ktx = new image::Ktx1Bundle( reinterpret_cast(sky_data.data()), std::uint32_t(sky_data.size())); - auto* sky_texture = - image::ktx::createTexture(&engine_, sky_ktx, false); + auto* sky_texture = ktxreader::Ktx1Reader::createTexture( + &engine_, sky_ktx, false); auto skybox = Skybox::Builder() .environment(sky_texture) diff --git a/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp b/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp index 66c39e04b35..36ec2634e8a 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp @@ -13,6 +13,7 @@ // 32 so that x >> 32 gives a warning. (Or maybe the compiler can't // determine the if statement does not run.) // 4305: LightManager.h needs to specify some constants as floats +#include #include #ifdef _MSC_VER @@ -151,6 +152,8 @@ FilamentScene::FilamentScene(filament::Engine& engine, : Scene(renderer), engine_(engine), resource_mgr_(resource_mgr) { scene_ = engine_.createScene(); CreateSunDirectionalLight(); + // Initialize background color to white (default) + background_color_ = Eigen::Vector4f(1.0f, 1.0f, 1.0f, 1.0f); // Note: can't set background color, because ImguiFilamentBridge // creates a Scene, and it needs to not have anything drawing, or it // covers up any SceneWidgets in the window. @@ -249,6 +252,15 @@ ViewHandle FilamentScene::AddView(std::int32_t x, c.view = std::move(view); views_.emplace(handle, std::move(c)); + // Set clear color on the renderer if background color has been set + // and there's no background image. This ensures the background color + // is visible even if the background geometry doesn't cover the entire + // viewport. Note: In Filament v1.58+, setClearColor was removed from View. + // Clear color is now set via Renderer::setClearOptions(). + if (!background_image_ && background_color_.w() > 0.0f) { + renderer_.SetClearColor(background_color_); + } + return handle; } @@ -659,12 +671,21 @@ void FilamentScene::UpdateGeometry(const std::string& object_name, } // Update the geometry to reflect new geometry count + // ******** NOTE ******** setGeometryAt changed - this code path needs + // to be tested!!!! if (geometry_update_needed) { auto& renderable_mgr = engine_.getRenderableManager(); auto inst = renderable_mgr.getInstance(g->filament_entity); +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" +#endif renderable_mgr.setGeometryAt( inst, 0, filament::RenderableManager::PrimitiveType::POINTS, - 0, n_vertices); + nullptr, nullptr, 0, n_vertices); +#if defined(__clang__) +#pragma clang diagnostic pop +#endif } } } @@ -1752,6 +1773,16 @@ void FilamentScene::SetBackground( } OverrideMaterial(kBackgroundName, m); background_image_ = new_image; + background_color_ = color; + + // Set clear color on the renderer when there's no background image. + // This ensures the background color is visible even when geometry doesn't + // cover the entire viewport. + // Note: In Filament v1.58+, setClearColor was removed from View. + // Clear color is now set via Renderer::setClearOptions(). + if (!new_image) { + renderer_.SetClearColor(color); + } } void FilamentScene::SetBackground(TextureHandle image) { @@ -1962,4 +1993,4 @@ void FilamentScene::HideRefractedMaterials(bool hide) { } // namespace rendering } // namespace visualization -} // namespace open3d +} // namespace open3d \ No newline at end of file diff --git a/cpp/open3d/visualization/rendering/filament/FilamentView.cpp b/cpp/open3d/visualization/rendering/filament/FilamentView.cpp index 1f8656bf6af..29a023a8a73 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentView.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentView.cpp @@ -57,7 +57,8 @@ FilamentView::FilamentView(filament::Engine& engine, FilamentResourceManager& resource_mgr) : engine_(engine), resource_mgr_(resource_mgr) { view_ = engine_.createView(); - view_->setSampleCount(4); + filament::MultiSampleAntiAliasingOptions msaao({true, 4, false}); + view_->setMultiSampleAntiAliasingOptions(msaao); SetAntiAliasing(true, false); SetPostProcessing(true); SetAmbientOcclusion(true, false); @@ -86,7 +87,14 @@ FilamentView::FilamentView(filament::Engine& engine, } FilamentView::~FilamentView() { +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" +#endif view_->setCamera(nullptr); +#if defined(__clang__) +#pragma clang diagnostic pop +#endif view_->setScene(nullptr); camera_.reset(); @@ -140,9 +148,16 @@ void FilamentView::SetWireframe(bool enable) { } } -void FilamentView::SetSampleCount(int n) { view_->setSampleCount(n); } +void FilamentView::SetSampleCount(int n) { + auto msaao = view_->getMultiSampleAntiAliasingOptions(); + msaao.sampleCount = n; + view_->setMultiSampleAntiAliasingOptions(msaao); +} -int FilamentView::GetSampleCount() const { return view_->getSampleCount(); } +int FilamentView::GetSampleCount() const { + auto msaao = view_->getMultiSampleAntiAliasingOptions(); + return msaao.sampleCount; +} void FilamentView::SetViewport(std::int32_t x, std::int32_t y, @@ -180,14 +195,12 @@ void FilamentView::SetBloom(bool enabled, } void FilamentView::SetAntiAliasing(bool enabled, bool temporal /* = false */) { - if (enabled) { - filament::View::TemporalAntiAliasingOptions options; - options.enabled = temporal; - view_->setAntiAliasing(filament::View::AntiAliasing::FXAA); - view_->setTemporalAntiAliasingOptions(options); - } else { - view_->setAntiAliasing(filament::View::AntiAliasing::NONE); - } + auto options = view_->getTemporalAntiAliasingOptions(); + auto msaao = view_->getMultiSampleAntiAliasingOptions(); + options.enabled = temporal; + msaao.enabled = enabled; + view_->setMultiSampleAntiAliasingOptions(msaao); + view_->setTemporalAntiAliasingOptions(options); } void FilamentView::SetShadowing(bool enabled, ShadowType type) { @@ -227,30 +240,34 @@ void FilamentView::SetColorGrading(const ColorGradingParams& color_grading) { break; } - filament::ColorGrading::ToneMapping tm = - filament::ColorGrading::ToneMapping::LINEAR; - switch (color_grading.GetToneMapping()) { - case ColorGradingParams::ToneMapping::kAcesLegacy: - tm = filament::ColorGrading::ToneMapping::ACES_LEGACY; - break; - case ColorGradingParams::ToneMapping::kAces: - tm = filament::ColorGrading::ToneMapping::ACES; - break; - case ColorGradingParams::ToneMapping::kFilmic: - tm = filament::ColorGrading::ToneMapping::FILMIC; - break; - case ColorGradingParams::ToneMapping::kUchimura: - tm = filament::ColorGrading::ToneMapping::UCHIMURA; - break; - case ColorGradingParams::ToneMapping::kReinhard: - tm = filament::ColorGrading::ToneMapping::REINHARD; - break; - case ColorGradingParams::ToneMapping::kDisplayRange: - tm = filament::ColorGrading::ToneMapping::DISPLAY_RANGE; - break; - default: - break; - } + // Tone mapping is not supported in Filament's ColorGrading::Builder API. + // The toneMapping() method was removed/deprecated in newer versions of + // Filament, so this code is commented out. The ToneMapping parameter in + // ColorGradingParams is kept for API compatibility but is not applied. + // filament::ColorGrading::ToneMapping tm = + // filament::ColorGrading::ToneMapping::LINEAR; + // switch (color_grading.GetToneMapping()) { + // case ColorGradingParams::ToneMapping::kAcesLegacy: + // tm = filament::ColorGrading::ToneMapping::ACES_LEGACY; + // break; + // case ColorGradingParams::ToneMapping::kAces: + // tm = filament::ColorGrading::ToneMapping::ACES; + // break; + // case ColorGradingParams::ToneMapping::kFilmic: + // tm = filament::ColorGrading::ToneMapping::FILMIC; + // break; + // case ColorGradingParams::ToneMapping::kUchimura: + // tm = filament::ColorGrading::ToneMapping::UCHIMURA; + // break; + // case ColorGradingParams::ToneMapping::kReinhard: + // tm = filament::ColorGrading::ToneMapping::REINHARD; + // break; + // case ColorGradingParams::ToneMapping::kDisplayRange: + // tm = filament::ColorGrading::ToneMapping::DISPLAY_RANGE; + // break; + // default: + // break; + // } if (color_grading_) { engine_.destroy(color_grading_); @@ -258,7 +275,7 @@ void FilamentView::SetColorGrading(const ColorGradingParams& color_grading) { color_grading_ = filament::ColorGrading::Builder() .quality(q) - .toneMapping(tm) + // .toneMapping(tm) .whiteBalance(color_grading.GetTemperature(), color_grading.GetTint()) .channelMixer( @@ -285,7 +302,7 @@ void FilamentView::SetColorGrading(const ColorGradingParams& color_grading) { } void FilamentView::ConfigureForColorPicking() { - view_->setSampleCount(1); + SetSampleCount(1); SetPostProcessing(false); SetAmbientOcclusion(false, false); SetShadowing(false, ShadowType::kPCF); @@ -355,7 +372,8 @@ void FilamentView::CopySettingsFrom(const FilamentView& other) { if (other.color_grading_) { view_->setColorGrading(other.color_grading_); } - view_->setSampleCount(other.view_->getSampleCount()); + view_->setMultiSampleAntiAliasingOptions( + other.view_->getMultiSampleAntiAliasingOptions()); auto ao_options = other.view_->getAmbientOcclusionOptions(); view_->setAmbientOcclusionOptions(ao_options); auto aa_mode = other.view_->getAntiAliasing(); @@ -386,8 +404,8 @@ void FilamentView::PreRender() { const auto n = camera_->GetNativeCamera()->getNear(); FilamentMaterialModifier(selected_material, material_handle) - .SetParameter("cameraNear", n) - .SetParameter("cameraFar", f) + .SetParameter("cameraNear", static_cast(n)) + .SetParameter("cameraFar", static_cast(f)) .Finish(); } } else if (mode_ == Mode::Normals) { @@ -463,4 +481,4 @@ void FilamentView::PostRender() {} } // namespace rendering } // namespace visualization -} // namespace open3d +} // namespace open3d \ No newline at end of file diff --git a/cpp/open3d/visualization/rendering/filament/LineSetBuffers.cpp b/cpp/open3d/visualization/rendering/filament/LineSetBuffers.cpp index 2e14cfbca48..573402289fa 100644 --- a/cpp/open3d/visualization/rendering/filament/LineSetBuffers.cpp +++ b/cpp/open3d/visualization/rendering/filament/LineSetBuffers.cpp @@ -181,7 +181,6 @@ LineSetBuffersBuilder::Buffers LineSetBuffersBuilder::ConstructThinLines() { VertexBuffer::AttributeType::FLOAT3, ColoredVertex::GetPositionOffset(), sizeof(ColoredVertex)) - .normalized(VertexAttribute::COLOR) .attribute(VertexAttribute::COLOR, 0, VertexBuffer::AttributeType::FLOAT4, ColoredVertex::GetColorOffset(), @@ -303,7 +302,6 @@ LineSetBuffersBuilder::Buffers LineSetBuffersBuilder::ConstructBuffers() { VertexBuffer::AttributeType::FLOAT4, ColoredVertex::GetNextOffset(), sizeof(ColoredVertex)) - .normalized(VertexAttribute::COLOR) .attribute(VertexAttribute::COLOR, 0, VertexBuffer::AttributeType::FLOAT4, ColoredVertex::GetColorOffset(), diff --git a/cpp/open3d/visualization/rendering/filament/PointCloudBuffers.cpp b/cpp/open3d/visualization/rendering/filament/PointCloudBuffers.cpp index f88db292b1f..774c1e1be6b 100644 --- a/cpp/open3d/visualization/rendering/filament/PointCloudBuffers.cpp +++ b/cpp/open3d/visualization/rendering/filament/PointCloudBuffers.cpp @@ -174,12 +174,10 @@ GeometryBuffersBuilder::Buffers PointCloudBuffersBuilder::ConstructBuffers() { VertexBuffer::AttributeType::FLOAT3, ColoredVertex::GetPositionOffset(), sizeof(ColoredVertex)) - .normalized(VertexAttribute::COLOR) .attribute(VertexAttribute::COLOR, 0, VertexBuffer::AttributeType::FLOAT4, ColoredVertex::GetColorOffset(), sizeof(ColoredVertex)) - .normalized(VertexAttribute::TANGENTS) .attribute(VertexAttribute::TANGENTS, 0, VertexBuffer::AttributeType::FLOAT4, ColoredVertex::GetTangentOffset(), @@ -350,10 +348,8 @@ GeometryBuffersBuilder::Buffers TPointCloudBuffersBuilder::ConstructBuffers() { .vertexCount(uint32_t(n_vertices)) .attribute(VertexAttribute::POSITION, 0, VertexBuffer::AttributeType::FLOAT3) - .normalized(VertexAttribute::COLOR) .attribute(VertexAttribute::COLOR, 1, VertexBuffer::AttributeType::FLOAT3) - .normalized(VertexAttribute::TANGENTS) .attribute(VertexAttribute::TANGENTS, 2, VertexBuffer::AttributeType::FLOAT4) .attribute(VertexAttribute::CUSTOM0, 2, diff --git a/cpp/open3d/visualization/rendering/filament/TriangleMeshBuffers.cpp b/cpp/open3d/visualization/rendering/filament/TriangleMeshBuffers.cpp index 776e7011191..d413496c96e 100644 --- a/cpp/open3d/visualization/rendering/filament/TriangleMeshBuffers.cpp +++ b/cpp/open3d/visualization/rendering/filament/TriangleMeshBuffers.cpp @@ -127,7 +127,6 @@ VertexBuffer* BuildFilamentVertexBuffer(filament::Engine& engine, VertexBuffer::AttributeType::FLOAT3, GetVertexPositionOffset(), stride) - .normalized(VertexAttribute::TANGENTS) .attribute(VertexAttribute::TANGENTS, 0, VertexBuffer::AttributeType::FLOAT4, GetVertexTangentOffset(), stride) @@ -137,10 +136,9 @@ VertexBuffer* BuildFilamentVertexBuffer(filament::Engine& engine, stride); if (has_colors) { - builder.normalized(VertexAttribute::COLOR) - .attribute(VertexAttribute::COLOR, 0, - VertexBuffer::AttributeType::FLOAT4, - GetVertexColorOffset(), stride); + builder.attribute(VertexAttribute::COLOR, 0, + VertexBuffer::AttributeType::FLOAT4, + GetVertexColorOffset(), stride); } if (has_uvs) { @@ -633,10 +631,8 @@ GeometryBuffersBuilder::Buffers TMeshBuffersBuilder::ConstructBuffers() { .vertexCount(uint32_t(n_vertices)) .attribute(VertexAttribute::POSITION, 0, VertexBuffer::AttributeType::FLOAT3) - .normalized(VertexAttribute::COLOR) .attribute(VertexAttribute::COLOR, 1, VertexBuffer::AttributeType::FLOAT3) - .normalized(VertexAttribute::TANGENTS) .attribute(VertexAttribute::TANGENTS, 2, VertexBuffer::AttributeType::FLOAT4) .attribute(VertexAttribute::CUSTOM0, 2, diff --git a/cpp/open3d/visualization/visualizer/ViewControlWithCustomAnimation.cpp b/cpp/open3d/visualization/visualizer/ViewControlWithCustomAnimation.cpp index dc4d9a77408..8d147dfbc7c 100644 --- a/cpp/open3d/visualization/visualizer/ViewControlWithCustomAnimation.cpp +++ b/cpp/open3d/visualization/visualizer/ViewControlWithCustomAnimation.cpp @@ -161,7 +161,7 @@ std::string ViewControlWithCustomAnimation::GetStatusString() const { if (view_trajectory_.view_status_.empty()) { buffer = "empty trajectory"; } else { - buffer = fmt::format(buffer, "#{} frame ({} in total{})", + buffer = fmt::format("#{} frame ({} in total{})", (unsigned int)CurrentFrame() + 1, (unsigned int)view_trajectory_.NumOfFrames(), view_trajectory_.is_loop_ ? ", looped" : ""); diff --git a/cpp/open3d/visualization/visualizer/VisualizerWithCustomAnimation.cpp b/cpp/open3d/visualization/visualizer/VisualizerWithCustomAnimation.cpp index fa13111961e..e01fbb76adb 100644 --- a/cpp/open3d/visualization/visualizer/VisualizerWithCustomAnimation.cpp +++ b/cpp/open3d/visualization/visualizer/VisualizerWithCustomAnimation.cpp @@ -107,17 +107,18 @@ void VisualizerWithCustomAnimation::Play( view_control.ConvertToPinholeCameraParameters(parameter); trajectory_ptr->parameters_.push_back(parameter); } - std::string buffer; if (recording_depth) { - buffer = fmt::format(recording_depth_filename_format_.c_str(), - recording_file_index_); - CaptureDepthImage( - recording_depth_basedir_ + std::string(buffer), false); + auto buffer = fmt::format( + fmt::runtime(recording_depth_basedir_ + + recording_depth_filename_format_), + recording_file_index_); + CaptureDepthImage(buffer, false); } else { - buffer = fmt::format(recording_image_filename_format_.c_str(), - recording_file_index_); - CaptureScreenImage( - recording_image_basedir_ + std::string(buffer), false); + auto buffer = fmt::format( + fmt::runtime(recording_depth_basedir_ + + recording_image_filename_format_), + recording_file_index_); + CaptureScreenImage(buffer, false); } } view_control.Step(1.0); diff --git a/cpp/open3d/visualization/webrtc_server/WebRTCWindowSystem.cpp b/cpp/open3d/visualization/webrtc_server/WebRTCWindowSystem.cpp index 667a7c88be4..10a2bd2bb9a 100644 --- a/cpp/open3d/visualization/webrtc_server/WebRTCWindowSystem.cpp +++ b/cpp/open3d/visualization/webrtc_server/WebRTCWindowSystem.cpp @@ -114,15 +114,7 @@ std::shared_ptr WebRTCWindowSystem::GetInstance() { } WebRTCWindowSystem::WebRTCWindowSystem() - : BitmapWindowSystem( -#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_WIN64) - BitmapWindowSystem::Rendering::HEADLESS -#else - BitmapWindowSystem::Rendering::NORMAL -#endif - ), - impl_(new WebRTCWindowSystem::Impl()) { - + : BitmapWindowSystem(), impl_(new WebRTCWindowSystem::Impl()) { // impl_->web_root_ is filled at StartWebRTCServer. It relies on // GetResourcePath(), which happens after Application::Initialize(). impl_->http_handshake_enabled_ = true; diff --git a/cpp/pybind/visualization/rendering/rendering.cpp b/cpp/pybind/visualization/rendering/rendering.cpp index 417f8d9d2ad..fd3ea179092 100644 --- a/cpp/pybind/visualization/rendering/rendering.cpp +++ b/cpp/pybind/visualization/rendering/rendering.cpp @@ -35,9 +35,6 @@ class PyOffscreenRenderer { gui::InitializeForPython(resource_path, true); width_ = width; height_ = height; - // NOTE: OffscreenRenderer now always uses headless so that a window - // system is never required - EngineInstance::EnableHeadless(); renderer_ = new FilamentRenderer(EngineInstance::GetInstance(), width, height, EngineInstance::GetResourceManager()); diff --git a/docker/Dockerfile.ci b/docker/Dockerfile.ci index cbad785399e..c3b1ee97fc2 100755 --- a/docker/Dockerfile.ci +++ b/docker/Dockerfile.ci @@ -145,13 +145,8 @@ COPY . /root/Open3D WORKDIR /root/Open3D # Open3D C++ dependencies -# If BUILD_SYCL_MODULE=ON, do not install clang - this installs libomp5-dev which gets linked into the shared library. -RUN if [[ "$(uname -m)" = "x86_64" ]] ; then \ - ./util/install_deps_ubuntu.sh assume-yes no-filament-deps ; \ - else \ - ./util/install_deps_ubuntu.sh assume-yes ; \ - fi - +# For build filament clang is needed (bundled with filament) +RUN ./util/install_deps_ubuntu.sh assume-yes # Open3D Python dependencies RUN source util/ci_utils.sh \ && if [ "${BUILD_CUDA_MODULE}" = "ON" ]; then \ diff --git a/docker/docker_build.sh b/docker/docker_build.sh index 582aaa459bb..733b587d858 100755 --- a/docker/docker_build.sh +++ b/docker/docker_build.sh @@ -72,8 +72,9 @@ OPTION: HOST_OPEN3D_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null 2>&1 && pwd)" # Shared variables -CMAKE_VERSION=cmake-3.29.2-linux-x86_64 -CMAKE_VERSION_AARCH64=cmake-3.24.4-linux-aarch64 +AARCH="$(uname -m)" +# do cmake pending on the architecture +CMAKE_VERSION=cmake-3.31.8-linux-${AARCH} CUDA_VERSION=12.6.3-cudnn CUDA_VERSION_LATEST=12.6.3-cudnn @@ -106,7 +107,7 @@ openblas_export_env() { export DOCKER_TAG=open3d-ci:openblas-arm64 export BASE_IMAGE=arm64v8/ubuntu:22.04 export CONDA_SUFFIX=aarch64 - export CMAKE_VERSION=${CMAKE_VERSION_AARCH64} + export CMAKE_VERSION=${CMAKE_VERSION} else echo "Invalid platform." print_usage_and_exit_docker_build diff --git a/examples/cpp/OffscreenRendering.cpp b/examples/cpp/OffscreenRendering.cpp index 18bc71d3b76..4d5cd37015d 100644 --- a/examples/cpp/OffscreenRendering.cpp +++ b/examples/cpp/OffscreenRendering.cpp @@ -16,7 +16,7 @@ using namespace open3d::visualization::rendering; // Headless rendering requires Open3D to be compiled with OSMesa support. // Add -DENABLE_HEADLESS_RENDERING=ON when you run CMake. -static const bool kUseHeadless = false; +static const bool kUseHeadless [[maybe_unused]] = false; static const std::string kOutputFilename = "offscreen.png"; @@ -26,9 +26,6 @@ int main(int argc, const char *argv[]) { auto &app = Application::GetInstance(); app.Initialize(argc, argv); - if (kUseHeadless) { - EngineInstance::EnableHeadless(); - } auto *renderer = new FilamentRenderer(EngineInstance::GetInstance(), width, height, diff --git a/util/ci_utils.sh b/util/ci_utils.sh index dc5182f159b..8a0a79225e3 100644 --- a/util/ci_utils.sh +++ b/util/ci_utils.sh @@ -31,8 +31,8 @@ TENSORFLOW_VER="2.19.0" TORCH_VER="2.7.1" TORCH_REPO_URL="https://download.pytorch.org/whl/torch/" # Python -PIP_VER="24.3.1" -PROTOBUF_VER="4.24.0" +PIP_VER="25.1.1" +PROTOBUF_VER="6.31.1" OPEN3D_INSTALL_DIR=~/open3d_install OPEN3D_SOURCE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null 2>&1 && pwd)" @@ -140,7 +140,14 @@ build_pip_package() { echo "Building Open3D wheel" options="$(echo "$@" | tr ' ' '|')" - BUILD_FILAMENT_FROM_SOURCE=OFF + AARCH="$(uname -m)" + if [[ "$AARCH" == "aarch64" ]]; then + echo "Building for aarch64 architecture" + BUILD_FILAMENT_FROM_SOURCE=ON + else + echo "Building for x86_64 architecture" + BUILD_FILAMENT_FROM_SOURCE=ON + fi set +u if [[ -f "${OPEN3D_ML_ROOT}/set_open3d_ml_root.sh" ]] && [[ "$BUILD_TENSORFLOW_OPS" == "ON" || "$BUILD_PYTORCH_OPS" == "ON" ]]; then @@ -165,9 +172,11 @@ build_pip_package() { if [[ "build_jupyter" =~ ^($options)$ ]]; then echo "Building Jupyter extension in Python wheel." BUILD_JUPYTER_EXTENSION=ON + BUILD_WEBRTC_FROM_SOURCE=ON else echo "Jupyter extension disabled in Python wheel." BUILD_JUPYTER_EXTENSION=OFF + BUILD_WEBRTC_FROM_SOURCE=OFF fi set -u @@ -184,6 +193,7 @@ build_pip_package() { "-DBUILD_PYTORCH_OPS=$BUILD_PYTORCH_OPS" "-DBUILD_FILAMENT_FROM_SOURCE=$BUILD_FILAMENT_FROM_SOURCE" "-DBUILD_JUPYTER_EXTENSION=$BUILD_JUPYTER_EXTENSION" + "-DBUILD_WEBRTC=$BUILD_WEBRTC_FROM_SOURCE" "-DCMAKE_INSTALL_PREFIX=$OPEN3D_INSTALL_DIR" "-DCMAKE_BUILD_TYPE=Release" "-DBUILD_UNIT_TESTS=OFF"