From e3b454ea46f587a9501c4d959310c024753f78a7 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 10 Jan 2026 21:49:29 +0800 Subject: [PATCH] prepare cuda deliver dev --- BasaltPresenter/CMakeLists.txt | 2 +- .../Plugins/Deliver/CMakeLists.txt | 6 ++-- .../Deliver/CudaDeliver/CMakeLists.txt | 28 +++++++++++++++++++ .../Plugins/Deliver/CudaDeliver/main.cpp | 23 +++++++++++++++ .../Plugins/Deliver/PipeDeliver/main.cpp | 18 ++++++++++-- .../Plugins/Engine/DirectX11Engine/main.cpp | 2 +- BasaltPresenter/README.md | 9 +++++- 7 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 BasaltPresenter/Plugins/Deliver/CudaDeliver/CMakeLists.txt create mode 100644 BasaltPresenter/Plugins/Deliver/CudaDeliver/main.cpp diff --git a/BasaltPresenter/CMakeLists.txt b/BasaltPresenter/CMakeLists.txt index b73068f..6f176a9 100644 --- a/BasaltPresenter/CMakeLists.txt +++ b/BasaltPresenter/CMakeLists.txt @@ -43,7 +43,7 @@ set(CMAKE_MODULE_PATH # Find required packages based on options find_package(spdlog REQUIRED) if (BASALT_CUDA_DELIVER) - find_package(CUDA REQUIRED) + find_package(CUDAToolkit REQUIRED) endif () if (BASALT_DIRECTX11_ENGINE) find_package(DirectX11 REQUIRED) diff --git a/BasaltPresenter/Plugins/Deliver/CMakeLists.txt b/BasaltPresenter/Plugins/Deliver/CMakeLists.txt index ae5021d..eef5c79 100644 --- a/BasaltPresenter/Plugins/Deliver/CMakeLists.txt +++ b/BasaltPresenter/Plugins/Deliver/CMakeLists.txt @@ -1,6 +1,6 @@ -# if (BASALT_CUDA_DELIVER) -# add_subdirectory(CudaDeliver) -# endif () +if (BASALT_CUDA_DELIVER) + add_subdirectory(CudaDeliver) +endif () # if (BASALT_ROCM_DELIVER) # add_subdirectory(RocmDeliver) # endif () diff --git a/BasaltPresenter/Plugins/Deliver/CudaDeliver/CMakeLists.txt b/BasaltPresenter/Plugins/Deliver/CudaDeliver/CMakeLists.txt new file mode 100644 index 0000000..1f69997 --- /dev/null +++ b/BasaltPresenter/Plugins/Deliver/CudaDeliver/CMakeLists.txt @@ -0,0 +1,28 @@ +# Create shared library +add_library(BasaltCudaDeliver SHARED "") +# Setup sources +target_sources(BasaltCudaDeliver +PRIVATE + main.cpp +) +# Setup header infomation +target_include_directories(BasaltCudaDeliver +PRIVATE + "${CMAKE_CURRENT_LIST_DIR}" +) +# Setup linked library infomation +target_link_libraries(BasaltCudaDeliver +PRIVATE + BasaltShared + CUDA::cudart +) +# Enable export macro +target_compile_definitions(BasaltCudaDeliver +PRIVATE + BS_EXPORTING +) + +# Install BasaltCudaDeliver only on Release mode +install(TARGETS BasaltCudaDeliver + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/plugin/deliver" +) diff --git a/BasaltPresenter/Plugins/Deliver/CudaDeliver/main.cpp b/BasaltPresenter/Plugins/Deliver/CudaDeliver/main.cpp new file mode 100644 index 0000000..0f40442 --- /dev/null +++ b/BasaltPresenter/Plugins/Deliver/CudaDeliver/main.cpp @@ -0,0 +1,23 @@ +#include +#include + +namespace deliver = ::basalt::shared::deliver; +using deliver::DeliverConfig; +using deliver::IDeliver; + +class CudaDeliver : public IDeliver { +public: + CudaDeliver() {} + virtual ~CudaDeliver() {} + +public: + +}; + +BS_EXPORT void* BSCreateInstance() { + return static_cast(new CudaDeliver()); +} + +BS_EXPORT void BSDestroyInstance(void* instance) { + delete dynamic_cast(static_cast(instance)); +} diff --git a/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp b/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp index ab428f5..8a97274 100644 --- a/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp +++ b/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp @@ -1,9 +1,23 @@ #include +#include + +namespace deliver = ::basalt::shared::deliver; +using deliver::DeliverConfig; +using deliver::IDeliver; + +class PipeDeliver : public IDeliver { +public: + PipeDeliver() {} + virtual ~PipeDeliver() {} + +public: + +}; BS_EXPORT void* BSCreateInstance() { - return nullptr; + return static_cast(new PipeDeliver()); } BS_EXPORT void BSDestroyInstance(void* instance) { - return; + delete dynamic_cast(static_cast(instance)); } diff --git a/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp b/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp index e3e8013..b53b29e 100644 --- a/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp +++ b/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp @@ -424,4 +424,4 @@ BS_EXPORT void* BSCreateInstance() { BS_EXPORT void BSDestroyInstance(void* instance) { delete dynamic_cast(static_cast(instance)); -} \ No newline at end of file +} diff --git a/BasaltPresenter/README.md b/BasaltPresenter/README.md index 9883db9..d21c1b3 100644 --- a/BasaltPresenter/README.md +++ b/BasaltPresenter/README.md @@ -2,12 +2,19 @@ ## Dependencies +* CUDA * [spdlog](https://github.com/gabime/spdlog) * [tinyobjloader](https://github.com/tinyobjloader/tinyobjloader) -* [cgltf](https://github.com/jkuhlmann/cgltf) + We assume that you executing following commands in the root directory of `BasaltPresenter` project. +### CUDA + +##### Usage + +Use `-DCUDAToolkit_ROOT=` in cmake when you configure this project. + ### spdlog ##### Build