Skip to content

Commit

Permalink
Hide symbols from core and visualization to reduce Windows DLL size.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey committed Dec 11, 2024
1 parent 773f765 commit d9ae308
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 28 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ if(WIN32)
# Then, we could use -fvisibility=hidden for Linux as well
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(MSVC)
add_compile_options("/permissive-") # MSVC standards-compliant mode
# Make sure we don't hit the 65535 object member limit with MSVC
#
# /bigobj allows object files with more than 65535 members
Expand Down
2 changes: 2 additions & 0 deletions cpp/open3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ target_sources(Open3D PRIVATE
open3d_ispc_target_sources_TARGET_OBJECTS(Open3D PRIVATE
camera
core
core_impl
data
geometry
tgeometry
Expand All @@ -101,6 +102,7 @@ open3d_ispc_target_sources_TARGET_OBJECTS(Open3D PRIVATE
tpipelines_kernel
utility
visualization
visualization_impl
)

if (BUILD_GUI)
Expand Down
47 changes: 31 additions & 16 deletions cpp/open3d/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,7 @@ target_sources(core PRIVATE
hashmap/HashBackendBuffer.cpp
hashmap/HashMap.cpp
hashmap/HashSet.cpp
kernel/Arange.cpp
kernel/ArangeCPU.cpp
kernel/BinaryEW.cpp
kernel/BinaryEWCPU.cpp
kernel/IndexGetSet.cpp
kernel/IndexGetSetCPU.cpp
kernel/IndexReduction.cpp
kernel/IndexReductionCPU.cpp
kernel/Kernel.cpp
kernel/NonZero.cpp
kernel/NonZeroCPU.cpp
kernel/Reduction.cpp
kernel/ReductionCPU.cpp
kernel/UnaryEW.cpp
kernel/UnaryEWCPU.cpp
kernel/UnaryEWSYCL.cpp
linalg/AddMM.cpp
linalg/AddMMCPU.cpp
linalg/Det.cpp
Expand All @@ -82,11 +67,33 @@ target_sources(core PRIVATE
nns/NNSIndex.cpp
)

# core_impl contains the implementation of core functions that are not exposed in the public API
open3d_ispc_add_library(core_impl OBJECT)
set_target_properties(core_impl PROPERTIES CXX_VISIBILITY_PRESET "hidden")

target_sources(core_impl PRIVATE
kernel/Arange.cpp
kernel/ArangeCPU.cpp
kernel/BinaryEW.cpp
kernel/BinaryEWCPU.cpp
kernel/IndexGetSet.cpp
kernel/IndexGetSetCPU.cpp
kernel/IndexReduction.cpp
kernel/IndexReductionCPU.cpp
kernel/NonZero.cpp
kernel/NonZeroCPU.cpp
kernel/Reduction.cpp
kernel/ReductionCPU.cpp
kernel/UnaryEW.cpp
kernel/UnaryEWCPU.cpp
kernel/UnaryEWSYCL.cpp
)

if (BUILD_CUDA_MODULE)
target_sources(core PRIVATE
MemoryManagerCUDA.cpp
)
target_sources(core PRIVATE
target_sources(core_impl PRIVATE
hashmap/CUDA/CreateCUDAHashBackend.cu
hashmap/CUDA/CUDAHashBackendBuffer.cu
hashmap/CUDA/SlabNodeManager.cu
Expand Down Expand Up @@ -116,6 +123,8 @@ endif()
if (BUILD_ISPC_MODULE)
target_sources(core PRIVATE
Indexer.ispc
)
target_sources(core_impl PRIVATE
kernel/BinaryEWCPU.ispc
kernel/UnaryEWCPU.ispc
)
Expand All @@ -126,6 +135,12 @@ open3d_set_global_properties(core)
open3d_set_open3d_lib_properties(core)
open3d_link_3rdparty_libraries(core)

open3d_show_and_abort_on_warning(core_impl)
open3d_set_global_properties(core_impl)
open3d_set_open3d_lib_properties(core_impl)
open3d_link_3rdparty_libraries(core_impl)

if(BUILD_CUDA_MODULE)
target_include_directories(core SYSTEM PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_include_directories(core_impl SYSTEM PRIVATE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
endif()
2 changes: 2 additions & 0 deletions cpp/open3d/geometry/SurfaceReconstructionBallPivoting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace open3d {
namespace geometry {
namespace {

class BallPivotingVertex;
class BallPivotingEdge;
Expand Down Expand Up @@ -733,6 +734,7 @@ class BallPivoting {
std::vector<BallPivotingVertexPtr> vertices;
std::shared_ptr<TriangleMesh> mesh_;
};
} // namespace

std::shared_ptr<TriangleMesh> TriangleMesh::CreateFromPointCloudBallPivoting(
const PointCloud& pcd, const std::vector<double>& radii) {
Expand Down
13 changes: 6 additions & 7 deletions cpp/open3d/geometry/SurfaceReconstructionPoisson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace open3d {
namespace geometry {
namespace poisson {
namespace {

// The order of the B-Spline used to splat in data for color interpolation
static const int DATA_DEGREE = 0;
Expand Down Expand Up @@ -713,7 +713,7 @@ void Execute(const open3d::geometry::PointCloud& pcd,
Time() - startTime, FEMTree<Dim, Real>::MaxMemoryUsage());
}

} // namespace poisson
} // namespace

std::tuple<std::shared_ptr<TriangleMesh>, std::vector<double>>
TriangleMesh::CreateFromPointCloudPoisson(const PointCloud& pcd,
Expand All @@ -722,10 +722,9 @@ TriangleMesh::CreateFromPointCloudPoisson(const PointCloud& pcd,
float scale,
bool linear_fit,
int n_threads) {
static const BoundaryType BType = poisson::DEFAULT_FEM_BOUNDARY;
static const BoundaryType BType = DEFAULT_FEM_BOUNDARY;
typedef IsotropicUIntPack<
poisson::DIMENSION,
FEMDegreeAndBType</* Degree */ 1, BType>::Signature>
DIMENSION, FEMDegreeAndBType</* Degree */ 1, BType>::Signature>
FEMSigs;

if (!pcd.HasNormals()) {
Expand All @@ -746,8 +745,8 @@ TriangleMesh::CreateFromPointCloudPoisson(const PointCloud& pcd,

auto mesh = std::make_shared<TriangleMesh>();
std::vector<double> densities;
poisson::Execute<float>(pcd, mesh, densities, static_cast<int>(depth),
width, scale, linear_fit, FEMSigs());
Execute<float>(pcd, mesh, densities, static_cast<int>(depth), width, scale,
linear_fit, FEMSigs());

ThreadPool::Terminate();

Expand Down
18 changes: 13 additions & 5 deletions cpp/open3d/visualization/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
open3d_ispc_add_library(visualization OBJECT)

target_sources(visualization PRIVATE
open3d_ispc_add_library(visualization_impl OBJECT)
set_target_properties(visualization_impl PROPERTIES CXX_VISIBILITY_PRESET hidden)

target_sources(visualization_impl PRIVATE
shader/GeometryRenderer.cpp
shader/ImageMaskShader.cpp
shader/ImageShader.cpp
Expand Down Expand Up @@ -62,14 +65,14 @@ if (BUILD_GUI)
rendering/Renderer.cpp
rendering/RendererHandle.cpp
rendering/RotationInteractorLogic.cpp
rendering/filament/FilamentEngine.cpp
rendering/filament/FilamentRenderer.cpp
)

target_sources(visualization PRIVATE
target_sources(visualization_impl PRIVATE
rendering/filament/FilamentCamera.cpp
rendering/filament/FilamentEngine.cpp
rendering/filament/FilamentEntitiesMods.cpp
rendering/filament/FilamentGeometryBuffersBuilder.cpp
rendering/filament/FilamentRenderer.cpp
rendering/filament/FilamentRenderToBuffer.cpp
rendering/filament/FilamentResourceManager.cpp
rendering/filament/FilamentScene.cpp
Expand Down Expand Up @@ -131,14 +134,19 @@ open3d_add_encoded_shader(shader
# Source group for Visual Studio
add_source_group(shader/glsl)

add_dependencies(visualization shader)
add_dependencies(visualization_impl shader)


open3d_show_and_abort_on_warning(visualization)
open3d_set_global_properties(visualization)
open3d_set_open3d_lib_properties(visualization)
open3d_link_3rdparty_libraries(visualization)

open3d_show_and_abort_on_warning(visualization_impl)
open3d_set_global_properties(visualization_impl)
open3d_set_open3d_lib_properties(visualization_impl)
open3d_link_3rdparty_libraries(visualization_impl)

# export GUI_RESOURCE_DIR to parent scope
if (BUILD_GUI)
set(GUI_RESOURCE_DIR ${GUI_RESOURCE_DIR} PARENT_SCOPE)
Expand Down

0 comments on commit d9ae308

Please sign in to comment.