From cdca9b2a94c9d09e8930eef431dce4fa0b92abb1 Mon Sep 17 00:00:00 2001 From: "d.denker" Date: Thu, 14 Aug 2025 12:05:15 +0200 Subject: [PATCH 1/4] 14.08.2025 -Changed variables in RendererHandle.h and .cpp from uint16_t to uint32_t to prvent overfow errors. -Fixed the bug that Filament entities were not destroyed. -Fixed a little bug in SlabNodeManager.h --- .../core/hashmap/CUDA/SlabNodeManager.h | 2 +- .../rendering/RendererHandle.cpp | 2 +- .../visualization/rendering/RendererHandle.h | 22 +++++++++---------- .../rendering/filament/FilamentScene.cpp | 4 +++- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h b/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h index 9668c31005a..9c340582663 100644 --- a/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h +++ b/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h @@ -111,7 +111,7 @@ class SlabNodeManagerImpl { memory_block_bitmap_ | (1 << empty_lane)); if (read_bitmap == memory_block_bitmap_) { // Successful attempt. - memory_block_bitmap_ |= (1 << empty_lane); + memory_block_bitmap_ = memory_block_bitmap_ |= (1 << empty_lane); allocated_result = (super_block_index_ << kSuperBlockMaskBits) | (memory_block_index_ << kBlockMaskBits) | diff --git a/cpp/open3d/visualization/rendering/RendererHandle.cpp b/cpp/open3d/visualization/rendering/RendererHandle.cpp index 42d150788a7..71e3cec3ac0 100644 --- a/cpp/open3d/visualization/rendering/RendererHandle.cpp +++ b/cpp/open3d/visualization/rendering/RendererHandle.cpp @@ -13,7 +13,7 @@ namespace open3d { namespace visualization { namespace rendering { -std::array(EntityType::Count)> +std::array(EntityType::Count)> REHandle_abstract::uid_table; std::ostream& operator<<(std::ostream& os, const REHandle_abstract& uid) { diff --git a/cpp/open3d/visualization/rendering/RendererHandle.h b/cpp/open3d/visualization/rendering/RendererHandle.h index 8f328accb51..0a0a698e425 100644 --- a/cpp/open3d/visualization/rendering/RendererHandle.h +++ b/cpp/open3d/visualization/rendering/RendererHandle.h @@ -20,7 +20,7 @@ namespace visualization { namespace rendering { // If you add entry here, don't forget to update TypeToString! -enum class EntityType : std::uint16_t { +enum class EntityType : std::uint32_t { None = 0, View, @@ -47,11 +47,11 @@ enum class EntityType : std::uint16_t { struct REHandle_abstract { static const char* TypeToString(EntityType type); - static const std::uint16_t kBadId = 0; + static const std::uint32_t kBadId = 0; const EntityType type = EntityType::None; - inline size_t Hash() const { - return static_cast(type) << 16 | id; + inline uint64_t Hash() const { + return static_cast(type) << 32 | id; } bool operator==(const REHandle_abstract& other) const { @@ -70,16 +70,16 @@ struct REHandle_abstract { REHandle_abstract() : type(EntityType::None), id(kBadId) {} - std::uint16_t GetId() const { return id; } + std::uint32_t GetId() const { return id; } protected: - REHandle_abstract(const EntityType aType, const std::uint16_t aId) + REHandle_abstract(const EntityType aType, const std::uint32_t aId) : type(aType), id(aId) {} - static std::array(EntityType::Count)> + static std::array(EntityType::Count)> uid_table; - std::uint16_t id = kBadId; + std::uint32_t id = kBadId; }; std::ostream& operator<<(std::ostream& os, const REHandle_abstract& uid); @@ -91,7 +91,7 @@ struct REHandle : public REHandle_abstract { static const REHandle kBad; static REHandle Next() { - const auto index = static_cast(entityType); + const auto index = static_cast(entityType); auto id = ++uid_table[index]; if (id == REHandle_abstract::kBadId) { uid_table[index] = REHandle_abstract::kBadId + 1; @@ -113,7 +113,7 @@ struct REHandle : public REHandle_abstract { REHandle() : REHandle_abstract(entityType, REHandle_abstract::kBadId) {} REHandle(const REHandle& other) : REHandle_abstract(entityType, other.id) {} // Don't use this constructor unless you know what you are doing - explicit REHandle(std::uint16_t id) : REHandle_abstract(entityType, id) {} + explicit REHandle(std::uint32_t id) : REHandle_abstract(entityType, id) {} REHandle& operator=(const REHandle& other) { id = other.id; @@ -177,4 +177,4 @@ struct formatter< } }; } // namespace fmt -/// @endcond +/// @endcond \ No newline at end of file diff --git a/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp b/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp index 0afb898538a..ae422270ecf 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp @@ -1919,7 +1919,9 @@ void FilamentScene::RenderableGeometry::ReleaseResources( destroy_map(mat.maps.anisotropy_map); manager.Destroy(mat.mat_instance); - + + // destroy filament entity + utils::EntityManager::get().destroy(filament_entity); filament_entity.clear(); } From 105dac7fa1e1cff0c8ee4af0bcfc982e1b2679ee Mon Sep 17 00:00:00 2001 From: "d.denker" Date: Fri, 15 Aug 2025 07:45:18 +0200 Subject: [PATCH 2/4] Reverses the unnecessary change in SlabNodeManager.h --- cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h b/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h index 9c340582663..9668c31005a 100644 --- a/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h +++ b/cpp/open3d/core/hashmap/CUDA/SlabNodeManager.h @@ -111,7 +111,7 @@ class SlabNodeManagerImpl { memory_block_bitmap_ | (1 << empty_lane)); if (read_bitmap == memory_block_bitmap_) { // Successful attempt. - memory_block_bitmap_ = memory_block_bitmap_ |= (1 << empty_lane); + memory_block_bitmap_ |= (1 << empty_lane); allocated_result = (super_block_index_ << kSuperBlockMaskBits) | (memory_block_index_ << kBlockMaskBits) | From 7769cee978ed280e2d2e9c56f9bf514f0037688e Mon Sep 17 00:00:00 2001 From: "d.denker" Date: Thu, 28 Aug 2025 10:30:17 +0200 Subject: [PATCH 3/4] Style correction for FilamentScene.cpp --- .../visualization/rendering/filament/FilamentScene.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp b/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp index ae422270ecf..66c39e04b35 100644 --- a/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp +++ b/cpp/open3d/visualization/rendering/filament/FilamentScene.cpp @@ -1919,9 +1919,10 @@ void FilamentScene::RenderableGeometry::ReleaseResources( destroy_map(mat.maps.anisotropy_map); manager.Destroy(mat.mat_instance); - - // destroy filament entity + + // Destroy filament entity utils::EntityManager::get().destroy(filament_entity); + filament_entity.clear(); } From 90b6bbb2c39baf6a9f4d46a31dbefe0b7bfe9bda Mon Sep 17 00:00:00 2001 From: "d.denker" Date: Thu, 28 Aug 2025 10:37:19 +0200 Subject: [PATCH 4/4] Add linespace at the end of RendererHandle.h --- cpp/open3d/visualization/rendering/RendererHandle.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/open3d/visualization/rendering/RendererHandle.h b/cpp/open3d/visualization/rendering/RendererHandle.h index 0a0a698e425..e65992e7459 100644 --- a/cpp/open3d/visualization/rendering/RendererHandle.h +++ b/cpp/open3d/visualization/rendering/RendererHandle.h @@ -177,4 +177,4 @@ struct formatter< } }; } // namespace fmt -/// @endcond \ No newline at end of file +/// @endcond