Skip to content

Commit 3250e9c

Browse files
authored
Merge pull request #16 from uos/develop
RCCVulkan
2 parents 0f1a8c8 + 88a2720 commit 3250e9c

File tree

11 files changed

+610
-26
lines changed

11 files changed

+610
-26
lines changed

rmcl/CMakeLists.txt

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.16)
22
project(rmcl
33
LANGUAGES CXX C
4-
VERSION 2.3.0
4+
VERSION 2.4.0
55
)
66

77
option(BUILD_TESTS "Build tests" ON)
@@ -59,16 +59,19 @@ if(TARGET TBB::tbb)
5959
endif()
6060

6161
# only print warning for Rmagine version greater than RMAGINE_MAX_VERSION
62-
set(RMAGINE_MAX_VERSION "2.4.0")
62+
set(RMAGINE_MAX_VERSION "2.5.0")
6363

64-
find_package(rmagine 2.3.2
64+
find_package(rmagine 2.4.0
6565
COMPONENTS
6666
core
6767
OPTIONAL_COMPONENTS
6868
embree
6969
cuda
7070
optix
71+
vulkan
72+
vulkan-cuda-interop
7173
)
74+
# not quite sure if it is vulkan_cuda_interop or vulkan-cuda-interop or vulkanCudaInterop
7275

7376
if(rmagine_VERSION GREATER RMAGINE_MAX_VERSION)
7477
message(WARNING "Found Rmagine version: ${rmagine_VERSION} > Latest tested Rmagine version: ${RMAGINE_MAX_VERSION}. Compile at your own risk.")
@@ -94,6 +97,10 @@ if(TARGET rmagine::optix)
9497
option(DISABLE_OPTIX "Disable Rmagine OptiX backend Compilation" FALSE)
9598
endif()
9699

100+
if(TARGET rmagine::vulkan AND TARGET rmagine::vulkan-cuda-interop AND TARGET rmagine::cuda)
101+
option(DISABLE_VULKAN "Disable Rmagine Vulkan backend Compilation" FALSE)
102+
endif()
103+
97104
find_package(Eigen3 REQUIRED)
98105

99106
set(RMCL_LIBRARIES rmcl)
@@ -110,6 +117,10 @@ if(TARGET rmagine::optix AND NOT ${DISABLE_OPTIX})
110117
list(APPEND RMCL_LIBRARIES rmcl-optix)
111118
endif()
112119

120+
if(TARGET rmagine::vulkan AND TARGET rmagine::vulkan-cuda-interop AND TARGET rmagine::cuda AND NOT ${DISABLE_VULKAN})
121+
list(APPEND RMCL_LIBRARIES rmcl-vulkan)
122+
endif()
123+
113124
include_directories(
114125
include
115126
)
@@ -302,6 +313,44 @@ if(TARGET rmagine::optix AND NOT ${DISABLE_OPTIX})
302313
set(RMCL_OPTIX True)
303314
endif()
304315

316+
317+
# VULKAN
318+
if(TARGET rmagine::vulkan AND TARGET rmagine::vulkan-cuda-interop AND TARGET rmagine::cuda AND NOT ${DISABLE_VULKAN})
319+
add_library(rmcl-vulkan SHARED
320+
# math
321+
src/rmcl/registration/RCCVulkan.cpp
322+
)
323+
324+
target_link_libraries(rmcl-vulkan
325+
rmagine::vulkan
326+
rmagine::vulkan-cuda-interop
327+
rmagine::cuda
328+
${CUDA_LIBRARIES}
329+
)
330+
331+
target_include_directories(rmcl-vulkan
332+
PUBLIC
333+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
334+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/rmcl-${rmcl_VERSION}>
335+
)
336+
337+
set_target_properties(rmcl-vulkan
338+
PROPERTIES
339+
SOVERSION ${rmcl_VERSION_MAJOR}
340+
VERSION ${rmcl_VERSION}
341+
# CXX_STANDARD 17
342+
)
343+
344+
install(TARGETS rmcl-vulkan
345+
EXPORT rmcl-targets
346+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
347+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
348+
)
349+
350+
add_definitions(-DRMCL_VULKAN)
351+
set(RMCL_VULKAN True)
352+
endif()
353+
305354
### INSTALL
306355
include(CMakePackageConfigHelpers)
307356

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#ifndef RMCL_ROS_CORRECTION_RCC_VULKAN_HPP
2+
#define RMCL_ROS_CORRECTION_RCC_VULKAN_HPP
3+
4+
#include <rmagine/types/MemoryCuda.hpp>
5+
#include <rmagine/types/PointCloud.hpp>
6+
#include <rmagine/map/VulkanMap.hpp>
7+
8+
#include <rmagine/simulation/SphereSimulatorVulkan.hpp>
9+
#include <rmagine/simulation/PinholeSimulatorVulkan.hpp>
10+
#include <rmagine/simulation/O1DnSimulatorVulkan.hpp>
11+
#include <rmagine/simulation/OnDnSimulatorVulkan.hpp>
12+
13+
#include <rmagine/types/MemoryVulkanCudaInterop.hpp>
14+
15+
#include <rmcl/registration/CorrespondencesCUDA.hpp>
16+
17+
namespace rm = rmagine;
18+
19+
namespace rmcl
20+
{
21+
22+
/**
23+
* this is not a very mice way to handle the views, but i could not find a better way right now...
24+
*
25+
* views need to be recreated every time the results buffers get resized...
26+
*
27+
* however using these views to copy from vulkan memory to cuda memory is faster than copying directly,
28+
* because you dont need to fetch a file descriptor every time.
29+
*/
30+
struct ViewContainer
31+
{
32+
ViewContainer(rm::MemoryView<uint8_t, rm::DEVICE_LOCAL_VULKAN>& hits,
33+
rm::MemoryView<rm::Point, rm::DEVICE_LOCAL_VULKAN>& points,
34+
rm::MemoryView<rm::Vector, rm::DEVICE_LOCAL_VULKAN>& normals) :
35+
hits_view(hits), points_view(points), normals_view(normals) {}
36+
37+
rmagine::MemoryView<uint8_t, rm::VULKAN_AS_CUDA> hits_view;
38+
rmagine::MemoryView<rm::Point, rm::VULKAN_AS_CUDA> points_view;
39+
rmagine::MemoryView<rm::Vector, rm::VULKAN_AS_CUDA> normals_view;
40+
};
41+
using ViewContainerPtr = std::unique_ptr<ViewContainer>;
42+
43+
44+
45+
class RCCVulkanSpherical
46+
: public CorrespondencesCUDA
47+
, public rmagine::ModelSetter<rmagine::SphericalModel>
48+
, protected rmagine::SphereSimulatorVulkan
49+
{
50+
public:
51+
52+
RCCVulkanSpherical(
53+
rmagine::VulkanMapPtr map);
54+
55+
void setModel(const rmagine::SphericalModel& sensor_model);
56+
57+
virtual void setTsb(const rmagine::Transform& Tsb) override;
58+
59+
virtual void find(const rmagine::Transform& Tbm_est);
60+
61+
private:
62+
63+
rmagine::SphericalModel model_cache_;
64+
65+
//TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
66+
rmagine::Bundle<
67+
rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
68+
rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
69+
rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
70+
> model_buffers_vulkan_;
71+
72+
ViewContainerPtr viewContainer = nullptr;
73+
};
74+
75+
76+
class RCCVulkanPinhole
77+
: public CorrespondencesCUDA
78+
, public rmagine::ModelSetter<rmagine::PinholeModel>
79+
, protected rmagine::PinholeSimulatorVulkan
80+
{
81+
public:
82+
83+
RCCVulkanPinhole(
84+
rmagine::VulkanMapPtr map);
85+
86+
void setModel(const rmagine::PinholeModel& sensor_model);
87+
88+
virtual void setTsb(const rmagine::Transform& Tsb) override;
89+
90+
virtual void find(const rmagine::Transform& Tbm_est);
91+
92+
private:
93+
rmagine::PinholeModel model_cache_;
94+
95+
//TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
96+
rmagine::Bundle<
97+
rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
98+
rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
99+
rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
100+
> model_buffers_vulkan_;
101+
102+
ViewContainerPtr viewContainer = nullptr;
103+
};
104+
105+
106+
class RCCVulkanO1Dn
107+
: public CorrespondencesCUDA
108+
, public rmagine::ModelSetter<rmagine::O1DnModel>
109+
, protected rmagine::O1DnSimulatorVulkan
110+
{
111+
public:
112+
113+
RCCVulkanO1Dn(
114+
rmagine::VulkanMapPtr map);
115+
116+
void setModel(const rmagine::O1DnModel& sensor_model);
117+
118+
virtual void setTsb(const rmagine::Transform& Tsb) override;
119+
120+
virtual void find(const rmagine::Transform& Tbm_est);
121+
122+
private:
123+
rmagine::O1DnModel model_cache_;
124+
125+
//TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
126+
rmagine::Bundle<
127+
rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
128+
rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
129+
rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
130+
> model_buffers_vulkan_;
131+
132+
ViewContainerPtr viewContainer = nullptr;
133+
};
134+
135+
class RCCVulkanOnDn
136+
: public CorrespondencesCUDA
137+
, public rmagine::ModelSetter<rmagine::OnDnModel>
138+
, protected rmagine::OnDnSimulatorVulkan
139+
{
140+
public:
141+
142+
RCCVulkanOnDn(
143+
rmagine::VulkanMapPtr map);
144+
145+
void setModel(const rmagine::OnDnModel& sensor_model);
146+
147+
virtual void setTsb(const rmagine::Transform& Tsb) override;
148+
149+
virtual void find(const rmagine::Transform& Tbm_est);
150+
151+
private:
152+
rmagine::OnDnModel model_cache_;
153+
154+
//TODO: mapping in gegenrichtung nutzen, sobald es in rmagine existiert
155+
rmagine::Bundle<
156+
rmagine::Points<rm::DEVICE_LOCAL_VULKAN>, // model points
157+
rmagine::Normals<rm::DEVICE_LOCAL_VULKAN>, // model normals
158+
rmagine::Hits<rm::DEVICE_LOCAL_VULKAN> // correspondence mask
159+
> model_buffers_vulkan_;
160+
161+
ViewContainerPtr viewContainer = nullptr;
162+
};
163+
164+
165+
} // namespace rmcl
166+
167+
#endif // RMCL_ROS_CORRECTION_RCC_EMBREE_HPP

rmcl/package.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0"?>
22
<package format="2">
33
<name>rmcl</name>
4-
<version>2.3.0</version>
4+
<version>2.4.0</version>
55
<description>The rmcl package</description>
66

77
<maintainer email="amock@uos.de">Alexander Mock</maintainer>
88

9-
<license>BSD</license>
9+
<license>BSD-3-Clause</license>
1010
<author email="amock@uos.de">Alexander Mock</author>
1111

1212
<buildtool_depend>cmake</buildtool_depend>

0 commit comments

Comments
 (0)