Skip to content

Commit 5e6901c

Browse files
authored
Merge pull request #17 from uos/develop
Vulkan Backend
2 parents a14608c + 02adb57 commit 5e6901c

112 files changed

Lines changed: 11329 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.14)
22
project(rmagine
33
LANGUAGES CXX C
4-
VERSION 2.3.3)# TODO update this version when merging into main-branch
4+
VERSION 2.4.0)# TODO update this version when merging into main-branch
55

66
option(RMAGINE_BUILD_TOOLS "Build tools" ON)
77
option(RMAGINE_BUILD_TESTS "Build tests" ON)
@@ -122,6 +122,19 @@ if(NOT RMAGINE_OPTIX_DISABLE)
122122
add_subdirectory(src/rmagine_optix)
123123
endif(NOT RMAGINE_OPTIX_DISABLE)
124124

125+
### RMAGINE VULKAN COMPONENT
126+
option(RMAGINE_VULKAN_DISABLE "Disable rmagine::vulkan compilation" OFF)
127+
if(NOT RMAGINE_VULKAN_DISABLE)
128+
add_subdirectory(src/rmagine_vulkan)
129+
endif(NOT RMAGINE_VULKAN_DISABLE)
130+
131+
### RMAGINE VULKAN CUDA INTEROP COMPONENT
132+
option(RMAGINE_VULKAN_CUDA_INTEROP_DISABLE "Disable rmagine::vulkan-cuda-interop compilation" OFF)
133+
if(NOT RMAGINE_VULKAN_CUDA_INTEROP_DISABLE)
134+
add_subdirectory(src/rmagine_vulkan_cuda_interop)
135+
endif(NOT RMAGINE_VULKAN_CUDA_INTEROP_DISABLE)
136+
137+
### ALL LIBS
125138
message(STATUS "${BoldCyan}Components being built:${ColourReset}")
126139
foreach(LIBRARY ${RMAGINE_LIBRARIES})
127140
message(STATUS "- ${BoldGreen}${LIBRARY}${ColourReset}")
@@ -140,6 +153,13 @@ if(RMAGINE_BUILD_TOOLS)
140153
add_subdirectory(apps/rmagine_map_info)
141154
add_subdirectory(apps/rmagine_version)
142155
add_subdirectory(apps/rmagine_info)
156+
add_subdirectory(apps/rmagine_vulkan_benchmark)
157+
add_subdirectory(apps/rmagine_simulation_diff_calc)
158+
add_subdirectory(apps/rmagine_measurements/rmagine_measurements_embree)
159+
add_subdirectory(apps/rmagine_measurements/rmagine_measurements_optix)
160+
add_subdirectory(apps/rmagine_measurements/rmagine_measurements_vulkan)
161+
add_subdirectory(apps/rmagine_measurements/rmagine_measurements_map_files)
162+
add_subdirectory(apps/rmagine_measurements/rmagine_measurements_as_size)
143163
endif(RMAGINE_BUILD_TOOLS)
144164

145165
if(RMAGINE_BUILD_EXAMPLES)
@@ -150,6 +170,10 @@ endif(TARGET rmagine-embree)
150170
if(TARGET rmagine-optix)
151171
add_subdirectory(apps/rmagine_examples/rmagine_optix_scene)
152172
endif(TARGET rmagine-optix)
173+
174+
if(TARGET rmagine-vulkan)
175+
add_subdirectory(apps/rmagine_examples/rmagine_vulkan_scene)
176+
endif(TARGET rmagine-vulkan)
153177
endif(RMAGINE_BUILD_EXAMPLES)
154178

155179

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ colcon build
9595

9696
For more advanced options and detailed instructions, visit the [Wiki](https://uos.github.io/rmagine_docs/installation/).
9797

98+
99+
## Backends
100+
101+
Rmagine provides multiple computation backends that enable seamless switching between different hardware devices available on a robot. This makes it possible to either offload ray casting workloads to dedicated devices and free resources for other computations, or to utilize all available compute power for large-scale ray casting.
102+
103+
The supported backends differ in terms of device compatibility, acceleration capabilities, and platform availability.
104+
105+
106+
| Backend | Supported Devices | Acceleration | Notes |
107+
| ---------- | ------------------------------------ | -------------------- | ------------------------------------------------------------------------------------------------------- |
108+
| **Embree** | CPU | Software (CPU) | High-performance CPU-based ray tracing |
109+
| **OptiX** | NVIDIA GPUs with OptiX support | Hardware or software | Uses hardware ray tracing when available, otherwise software emulation; not available on Jetson devices |
110+
| **Vulkan** | GPUs with Vulkan ray tracing support | Hardware ray tracing | Cross-vendor solution; supported on desktop GPUs and embedded platforms such as Jetson |
111+
112+
113+
Each backend is compiled as an optional CMake component and is only enabled if all required dependencies are available on the system. Detailed instructions and further information on building the optional backends can be found in the [Wiki](https://uos.github.io/rmagine_docs).
114+
115+
98116
## Example
99117

100118
This example demonstrates how to simulate ranges for 100 Velodyne VLP-16 sensors using the Embree backend.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
if(TARGET rmagine::vulkan AND TARGET rmagine::cuda AND TARGET rmagine::optix)
2+
3+
add_executable(rmagine_measurements_as_size
4+
Main.cpp
5+
)
6+
7+
target_link_libraries(rmagine_measurements_as_size
8+
rmagine::core
9+
rmagine::cuda
10+
rmagine::optix
11+
rmagine::vulkan
12+
)
13+
14+
##### INSTALL
15+
install(TARGETS rmagine_measurements_as_size
16+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
17+
COMPONENT vulkan
18+
)
19+
20+
endif(TARGET rmagine::vulkan AND TARGET rmagine::cuda AND TARGET rmagine::optix)
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#include <filesystem>
2+
3+
// Core rmagine includes
4+
#include <rmagine/types/Memory.hpp>
5+
#include <rmagine/map/OptixMap.hpp>
6+
#include <rmagine/types/MemoryCuda.hpp>
7+
#include <rmagine/map/optix/optix_shapes.h>
8+
#include <rmagine/map/VulkanMap.hpp>
9+
#include <rmagine/types/MemoryVulkan.hpp>
10+
#include <rmagine/map/vulkan/vulkan_shapes.hpp>
11+
12+
13+
14+
15+
using namespace rmagine;
16+
17+
18+
VulkanMapPtr make_sphere_map_vulkan(unsigned int num_long, unsigned int num_lat)
19+
{
20+
VulkanScenePtr scene = std::make_shared<VulkanScene>();
21+
22+
VulkanMeshPtr mesh = std::make_shared<VulkanSphere>(num_long, num_lat);
23+
mesh->commit();
24+
scene->add(mesh);
25+
scene->commit();
26+
27+
return std::make_shared<VulkanMap>(scene);
28+
}
29+
30+
OptixMapPtr make_sphere_map_optix(unsigned int num_long, unsigned int num_lat)
31+
{
32+
OptixScenePtr scene = std::make_shared<OptixScene>();
33+
34+
OptixMeshPtr mesh = std::make_shared<OptixSphere>(num_long, num_lat);
35+
mesh->commit();
36+
scene->add(mesh);
37+
scene->commit();
38+
39+
return std::make_shared<OptixMap>(scene);
40+
}
41+
42+
43+
size_t num_maps = 20;
44+
size_t map_param = 500;
45+
46+
int main(int argc, char** argv)
47+
{
48+
//measure different num of faces
49+
std::vector<std::string> results_vulkan;
50+
std::vector<std::string> results_optix;
51+
std::vector<std::string> mesh_sizes_vert;
52+
std::vector<std::string> mesh_sizes_ind;
53+
std::vector<std::string> mesh_sizes_total;
54+
for(size_t i = 0; i <= num_maps; i++)
55+
{
56+
unsigned int num_lon_and_lat = static_cast<unsigned int>(static_cast<double>(map_param)*sqrt(static_cast<double>(i)));
57+
if(i == 0)
58+
num_lon_and_lat = 10;
59+
60+
{
61+
VulkanMapPtr map_vulkan = make_sphere_map_vulkan(num_lon_and_lat, num_lon_and_lat);
62+
std::cout << "Num Faces Vulkan: " << map_vulkan->scene()->geometries().begin()->second->this_shared<VulkanInst>()->scene()->geometries().begin()->second->this_shared<VulkanMesh>()->faces.size() << std::endl;
63+
size_t map_size_bytes_vulkan = map_vulkan->scene()->getAsSize();
64+
65+
std::stringstream point_vulkan;
66+
point_vulkan << "(" << static_cast<double>(map_vulkan->scene()->geometries().begin()->second->this_shared<VulkanInst>()->scene()->geometries().begin()->second->this_shared<VulkanMesh>()->faces.size())/1000000.0 << ", " << map_size_bytes_vulkan << ")";
67+
results_vulkan.push_back(point_vulkan.str());
68+
}
69+
70+
{
71+
OptixMapPtr map_optix = make_sphere_map_optix(num_lon_and_lat, num_lon_and_lat);
72+
std::cout << "Num Faces Optix: " << map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->faces.size() << std::endl;
73+
size_t map_size_bytes_optix = map_optix->scene()->getAsSize();
74+
75+
std::stringstream point_optix;
76+
point_optix << "(" << static_cast<double>(map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->faces.size())/1000000.0 << ", " << map_size_bytes_optix << ")";
77+
results_optix.push_back(point_optix.str());
78+
79+
//these two are the same for vulkan and optix:
80+
uint64_t vert_size = map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->vertices.size()*sizeof(rmagine::Point);
81+
uint64_t ind_size = map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->faces.size()*sizeof(rmagine::Face);
82+
uint64_t total_size = vert_size + ind_size;
83+
84+
std::stringstream point_vert;
85+
point_vert << "(" << static_cast<double>(map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->faces.size())/1000000.0 << ", " << vert_size << ")";
86+
mesh_sizes_vert.push_back(point_vert.str());
87+
88+
std::stringstream point_ind;
89+
point_ind << "(" << static_cast<double>(map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->faces.size())/1000000.0 << ", " << ind_size << ")";
90+
mesh_sizes_ind.push_back(point_ind.str());
91+
92+
std::stringstream point_total;
93+
point_total << "(" << static_cast<double>(map_optix->scene()->geometries().begin()->second->this_shared<OptixMesh>()->faces.size())/1000000.0 << ", " << total_size << ")";
94+
mesh_sizes_total.push_back(point_total.str());
95+
}
96+
}
97+
std::cout << std::endl;
98+
std::cout << "Vulkan:" << std::endl;
99+
for(size_t i = 0; i < results_vulkan.size(); i++)
100+
{
101+
std::cout << results_vulkan[i];
102+
}
103+
std::cout << std::endl;
104+
std::cout << std::endl;
105+
std::cout << "Optix:" << std::endl;
106+
for(size_t i = 0; i < results_optix.size(); i++)
107+
{
108+
std::cout << results_optix[i];
109+
}
110+
std::cout << std::endl;
111+
std::cout << std::endl;
112+
std::cout << "Vertex Buffer Sizes:" << std::endl;
113+
for(size_t i = 0; i < mesh_sizes_vert.size(); i++)
114+
{
115+
std::cout << mesh_sizes_vert[i];
116+
}
117+
std::cout << std::endl;
118+
std::cout << std::endl;
119+
std::cout << "Face Buffer Sizes:" << std::endl;
120+
for(size_t i = 0; i < mesh_sizes_ind.size(); i++)
121+
{
122+
std::cout << mesh_sizes_ind[i];
123+
}
124+
std::cout << std::endl;
125+
std::cout << std::endl;
126+
std::cout << "Total Mesh Sizes:" << std::endl;
127+
for(size_t i = 0; i < mesh_sizes_total.size(); i++)
128+
{
129+
std::cout << mesh_sizes_total[i];
130+
}
131+
std::cout << std::endl;
132+
133+
std::cout << "\nFinished." << std::endl;
134+
135+
return EXIT_SUCCESS;
136+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if(TARGET rmagine::embree)
2+
3+
add_executable(rmagine_measurements_embree
4+
Main.cpp
5+
)
6+
7+
target_link_libraries(rmagine_measurements_embree
8+
rmagine::core
9+
rmagine::embree
10+
)
11+
12+
##### INSTALL
13+
install(TARGETS rmagine_measurements_embree
14+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
15+
COMPONENT embree
16+
)
17+
18+
endif(TARGET rmagine::embree)

0 commit comments

Comments
 (0)