From f094dda054f830aa70c8a17b11212ad9e42e05aa Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 4 Jan 2026 16:12:36 +0800 Subject: [PATCH] prepare dx dev --- BasaltPresenter/CMake/FindDirectX11.cmake | 116 ++++++++++++++++++ BasaltPresenter/CMake/FindDirectX12.cmake | 47 +++++++ BasaltPresenter/CMake/FindDirectX9.cmake | 32 +++++ BasaltPresenter/CMakeLists.txt | 33 +++-- .../Plugins/AnimeLoader/CMakeLists.txt | 0 BasaltPresenter/Plugins/CMakeLists.txt | 4 + .../Plugins/Deliver/CMakeLists.txt | 5 + .../Deliver/PipeDeliver/CMakeLists.txt | 27 ++++ .../Plugins/Deliver/PipeDeliver/main.cpp | 9 ++ BasaltPresenter/Plugins/Engine/CMakeLists.txt | 6 + .../Engine/DirectX11Engine/CMakeLists.txt | 27 ++++ .../Plugins/Engine/DirectX11Engine/main.cpp | 9 ++ .../Plugins/ObjectLoader/CMakeLists.txt | 0 BasaltPresenter/Presenter/dll_loader.hpp | 8 +- BasaltPresenter/Shared/CMakeLists.txt | 10 +- BasaltPresenter/Shared/basalt_export.hpp | 36 ++++++ BasaltPresenter/Shared/deliver.cpp | 9 ++ BasaltPresenter/Shared/deliver.hpp | 18 +++ BasaltPresenter/Shared/engine.cpp | 9 ++ BasaltPresenter/Shared/engine.hpp | 36 ++++++ 20 files changed, 421 insertions(+), 20 deletions(-) create mode 100644 BasaltPresenter/CMake/FindDirectX11.cmake create mode 100644 BasaltPresenter/CMake/FindDirectX12.cmake create mode 100644 BasaltPresenter/CMake/FindDirectX9.cmake create mode 100644 BasaltPresenter/Plugins/AnimeLoader/CMakeLists.txt create mode 100644 BasaltPresenter/Plugins/Deliver/CMakeLists.txt create mode 100644 BasaltPresenter/Plugins/Deliver/PipeDeliver/CMakeLists.txt create mode 100644 BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp create mode 100644 BasaltPresenter/Plugins/Engine/CMakeLists.txt create mode 100644 BasaltPresenter/Plugins/Engine/DirectX11Engine/CMakeLists.txt create mode 100644 BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp create mode 100644 BasaltPresenter/Plugins/ObjectLoader/CMakeLists.txt create mode 100644 BasaltPresenter/Shared/basalt_export.hpp create mode 100644 BasaltPresenter/Shared/deliver.cpp create mode 100644 BasaltPresenter/Shared/deliver.hpp create mode 100644 BasaltPresenter/Shared/engine.cpp create mode 100644 BasaltPresenter/Shared/engine.hpp diff --git a/BasaltPresenter/CMake/FindDirectX11.cmake b/BasaltPresenter/CMake/FindDirectX11.cmake new file mode 100644 index 0000000..9b4911c --- /dev/null +++ b/BasaltPresenter/CMake/FindDirectX11.cmake @@ -0,0 +1,116 @@ +# Find DirectX11 SDK +# Define: +# DirectX11_FOUND +# DirectX11_INCLUDE_DIR +# DirectX11_LIBRARY + +if(WIN32) # The only platform it makes sense to check for DirectX11 SDK + if( MSVC AND NOT MSVC90 ) + # Windows 10.x SDK + get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH) + file(GLOB W10SDK_VERSIONS RELATIVE ${kit10_dir}/Include ${kit10_dir}/Include/10.*) # enumerate pre-release and not yet known release versions + list(APPEND W10SDK_VERSIONS "10.0.10240.0" "10.0.14393.0" "10.0.15063.0" "10.0.16299.0") # enumerate well known release versions + list(REMOVE_DUPLICATES W10SDK_VERSIONS) + list(SORT W10SDK_VERSIONS) + list(REVERSE W10SDK_VERSIONS) # sort from high to low + if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + list(INSERT W10SDK_VERSIONS 0 ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) # prefer version passed by CMake, if any + endif() + foreach(W10SDK_VER ${W10SDK_VERSIONS}) + find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "${kit10_dir}/Include/${W10SDK_VER}/um" "C:/Program Files (x86)/Windows Kits/10/Include/${W10SDK_VER}/um" "C:/Program Files/Windows Kits/10/Include/${W10SDK_VER}/um") + endforeach() + # Windows 8.1 SDK + if(NOT DirectX11_INCLUDE_DIR) + find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "C:/Program Files (x86)/Windows Kits/8.1/include/um" "C:/Program Files/Windows Kits/8.1/include/um") + endif() + # Windows 8.0 SDK + if(NOT DirectX11_INCLUDE_DIR) + find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS "C:/Program Files (x86)/Windows Kits/8.0/include/um" "C:/Program Files/Windows Kits/8.0/include/um") + endif() + endif() + + if(DirectX11_INCLUDE_DIR) + # No need to specify full path to libraries, proper version would be found as part of SDK, in one of the following places + # "C:/Program Files (x86)/Windows Kits/10/lib/${W10SDK_VER}/um/${MSVC_CXX_ARCHITECTURE_ID}/" + # "C:/Program Files (x86)/Windows Kits/8.1/lib/winv6.3/um/${MSVC_CXX_ARCHITECTURE_ID}/" + # "C:/Program Files (x86)/Windows Kits/8.0/lib/win8/um/${MSVC_CXX_ARCHITECTURE_ID}/" + # "C:/Program Files (x86)/Windows Phone Kits/8.1/lib/${MSVC_CXX_ARCHITECTURE_ID}/" + # "C:/Program Files (x86)/Windows Phone Kits/8.0/lib/${MSVC_CXX_ARCHITECTURE_ID}/" + set(DirectX11_LIBRARY d3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib) + # but it is usefull to output selected version to the log + message(STATUS "Found DirectX11 headers: ${DirectX11_INCLUDE_DIR}") + endif() + + # Legacy Direct X SDK + if( NOT DirectX11_INCLUDE_DIR OR NOT DirectX11_LIBRARY ) + # Get path, convert backslashes as ${ENV_DXSDK_DIR} + getenv_path(DXSDK_DIR) + getenv_path(DIRECTX_HOME) + getenv_path(DIRECTX_ROOT) + getenv_path(DIRECTX_BASE) + + # construct search paths + set(DirectX11_PREFIX_PATH + "${DXSDK_DIR}" "${ENV_DXSDK_DIR}" + "${DIRECTX_HOME}" "${ENV_DIRECTX_HOME}" + "${DIRECTX_ROOT}" "${ENV_DIRECTX_ROOT}" + "${DIRECTX_BASE}" "${ENV_DIRECTX_BASE}" + "C:/apps_x86/Microsoft DirectX SDK*" + "C:/Program Files (x86)/Microsoft DirectX SDK*" + "C:/apps/Microsoft DirectX SDK*" + "C:/Program Files/Microsoft DirectX SDK*" + "$ENV{ProgramFiles}/Microsoft DirectX SDK*" + ) + + create_search_paths(DirectX11) + # redo search if prefix path changed + clear_if_changed(DirectX11_PREFIX_PATH + DirectX11_LIBRARY + DirectX11_INCLUDE_DIR + ) + + # dlls are in DirectX11_ROOT_DIR/Developer Runtime/x64|x86 + # lib files are in DirectX11_ROOT_DIR/Lib/x64|x86 + if(CMAKE_CL_64) + set(DirectX11_LIBPATH_SUFFIX "x64") + else(CMAKE_CL_64) + set(DirectX11_LIBPATH_SUFFIX "x86") + endif(CMAKE_CL_64) + + # look for D3D11 components + find_path(DirectX11_INCLUDE_DIR NAMES d3d11.h HINTS ${DirectX11_INC_SEARCH_PATH}) + find_library(DirectX11_DXERR_LIBRARY NAMES DxErr HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX}) + find_library(DirectX11_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX}) + find_library(DirectX11_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX}) + find_library(DirectX11_D3DCOMPILER_LIBRARY NAMES d3dcompiler HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX}) + find_library(DirectX11_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX}) + find_library(DirectX11_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX11_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX11_LIBPATH_SUFFIX}) + + if (DirectX11_INCLUDE_DIR AND DirectX11_D3D11_LIBRARY) + set(DirectX11_D3D11_LIBRARIES ${DirectX11_D3D11_LIBRARIES} + ${DirectX11_D3D11_LIBRARY} + ${DirectX11_DXGI_LIBRARY} + ${DirectX11_DXGUID_LIBRARY} + ${DirectX11_D3DCOMPILER_LIBRARY} + ) + endif () + if (DirectX11_D3DX11_LIBRARY) + set(DirectX11_D3D11_LIBRARIES ${DirectX11_D3D11_LIBRARIES} ${DirectX11_D3DX11_LIBRARY}) + endif () + if (DirectX11_DXERR_LIBRARY) + set(DirectX11_D3D11_LIBRARIES ${DirectX11_D3D11_LIBRARIES} ${DirectX11_DXERR_LIBRARY}) + endif () + + set(DirectX11_LIBRARY + ${DirectX11_D3D11_LIBRARIES} + ) + + mark_as_advanced(DirectX11_D3D11_LIBRARY + DirectX11_D3DX11_LIBRARY + DirectX11_DXERR_LIBRARY + DirectX11_DXGUID_LIBRARY + DirectX11_DXGI_LIBRARY + DirectX11_D3DCOMPILER_LIBRARY) + endif () # Legacy Direct X SDK + +endif(WIN32) \ No newline at end of file diff --git a/BasaltPresenter/CMake/FindDirectX12.cmake b/BasaltPresenter/CMake/FindDirectX12.cmake new file mode 100644 index 0000000..7a977a6 --- /dev/null +++ b/BasaltPresenter/CMake/FindDirectX12.cmake @@ -0,0 +1,47 @@ +## Stolen from https://github.com/Microsoft/DirectXShaderCompiler/blob/main/cmake/modules/FindD3D12.cmake +# Find the Win10 SDK path. +if ("$ENV{WIN10_SDK_PATH}$ENV{WIN10_SDK_VERSION}" STREQUAL "" ) + get_filename_component(WIN10_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE CACHE) + set (WIN10_SDK_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}) +elseif(TRUE) + set (WIN10_SDK_PATH $ENV{WIN10_SDK_PATH}) + set (WIN10_SDK_VERSION $ENV{WIN10_SDK_VERSION}) +endif ("$ENV{WIN10_SDK_PATH}$ENV{WIN10_SDK_VERSION}" STREQUAL "" ) + +# WIN10_SDK_PATH will be something like C:\Program Files (x86)\Windows Kits\10 +# WIN10_SDK_VERSION will be something like 10.0.14393 or 10.0.14393.0; we need the +# one that matches the directory name. + +if (IS_DIRECTORY "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}.0") + set(WIN10_SDK_VERSION "${WIN10_SDK_VERSION}.0") +endif (IS_DIRECTORY "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}.0") + + +# Find the d3d12 and dxgi include path, it will typically look something like this. +# C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um\d3d12.h +# C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared\dxgi1_4.h +find_path(DirectX12_INCLUDE_DIR # Set variable DirectX12_INCLUDE_DIR + d3d12.h # Find a path with d3d12.h + HINTS "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}/um" + DOC "path to WIN10 SDK header files" + HINTS + ) + +find_path(DXGI_INCLUDE_DIR # Set variable DXGI_INCLUDE_DIR + dxgi1_4.h # Find a path with dxgi1_4.h + HINTS "${WIN10_SDK_PATH}/Include/${WIN10_SDK_VERSION}/shared" + DOC "path to WIN10 SDK header files" + HINTS + ) +set(DirectX12_INCLUDE_DIRS ${DirectX12_INCLUDE_DIR} ${DXGI_INCLUDE_DIR}) + +# List of D3D libraries +set(DirectX12_LIBRARY d3d12.lib dxgi.lib d3dcompiler.lib dxguid.lib) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set D3D12_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(DirectX12 DEFAULT_MSG + DirectX12_INCLUDE_DIRS DirectX12_LIBRARY) + +mark_as_advanced(DirectX12_INCLUDE_DIRS DirectX12_LIBRARY) \ No newline at end of file diff --git a/BasaltPresenter/CMake/FindDirectX9.cmake b/BasaltPresenter/CMake/FindDirectX9.cmake new file mode 100644 index 0000000..64e0b8e --- /dev/null +++ b/BasaltPresenter/CMake/FindDirectX9.cmake @@ -0,0 +1,32 @@ +# Find the DirectX 9 includes and library +# This module defines: +# DIRECTX9_INCLUDE_DIRS, where to find d3d9.h, etc. +# DIRECTX9_LIBRARIES, libraries to link against to use DirectX. +# DIRECTX9_FOUND, If false, do not try to use DirectX. +# DIRECTX9_ROOT_DIR, directory where DirectX was installed. + +set(DIRECTX9_INCLUDE_PATHS + "$ENV{DXSDK_DIR}/Include" + "$ENV{DIRECTX_ROOT}/Include" + "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include" + "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include" +) +find_path(DIRECTX9_INCLUDE_DIRS d3dx9.h ${DIRECTX9_INCLUDE_PATHS} NO_DEFAULT_PATH) + +get_filename_component(DIRECTX9_ROOT_DIR "${DIRECTX9_INCLUDE_DIRS}/.." ABSOLUTE) + +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(DIRECTX9_LIBRARY_PATHS "${DIRECTX9_ROOT_DIR}/Lib/x64") +else () + set(DIRECTX9_LIBRARY_PATHS "${DIRECTX9_ROOT_DIR}/Lib/x86" "${DIRECTX9_ROOT_DIR}/Lib") +endif () + +find_library(DIRECTX9_D3D9_LIBRARY d3d9 ${DIRECTX9_LIBRARY_PATHS} NO_DEFAULT_PATH) +find_library(DIRECTX9_D3DX9_LIBRARY d3dx9 ${DIRECTX9_LIBRARY_PATHS} NO_DEFAULT_PATH) +find_library(DIRECTX9_DXERR_LIBRARY DxErr ${DIRECTX9_LIBRARY_PATHS} NO_DEFAULT_PATH) +set(DIRECTX9_LIBRARIES ${DIRECTX9_D3D9_LIBRARY} ${DIRECTX9_D3DX9_LIBRARY} ${DIRECTX9_DXERR_LIBRARY}) + +# handle the QUIETLY and REQUIRED arguments and set DIRECTX9_FOUND to TRUE if all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(DirectX9 DEFAULT_MSG DIRECTX9_ROOT_DIR DIRECTX9_LIBRARIES DIRECTX9_INCLUDE_DIRS) +mark_as_advanced(DIRECTX9_INCLUDE_DIRS DIRECTX9_D3D9_LIBRARY DIRECTX9_D3DX9_LIBRARY DIRECTX9_DXERR_LIBRARY) \ No newline at end of file diff --git a/BasaltPresenter/CMakeLists.txt b/BasaltPresenter/CMakeLists.txt index cd99e65..ccd5198 100644 --- a/BasaltPresenter/CMakeLists.txt +++ b/BasaltPresenter/CMakeLists.txt @@ -9,15 +9,18 @@ project(Basalt # Provide options # Render Engines +# option(BASALT_DIRECTX8_ENGINE "Build with DirectX 8 render engine support." OFF) +# option(BASALT_DIRECTX9_ENGINE "Build with DirectX 9 render engine support." OFF) option(BASALT_DIRECTX11_ENGINE "Build with DirectX 11 render engine support." OFF) -option(BASALT_OPENGL_ENGINE "Build with OpenGL render engine support." OFF) -option(BASALT_VULKAN_ENGINE "Build with Vulkan render engine support." OFF) +# option(BASALT_DIRECTX12_ENGINE "Build with DirectX 12 render engine support." OFF) +# option(BASALT_OPENGL_ENGINE "Build with OpenGL render engine support." OFF) +# option(BASALT_VULKAN_ENGINE "Build with Vulkan render engine support." OFF) # Data Delivers option(BASALT_CUDA_DELIVER "Build with CUDA data deliver support." OFF) -option(BASALT_ROCM_DELIVER "Build with ROCm data deliver support." OFF) +# option(BASALT_ROCM_DELIVER "Build with ROCm data deliver support." OFF) option(BASALT_PIPE_DELIVER "Build with system pipe data deliver support." OFF) -option(BASALT_TCP_DELIVER "Build with TCP data deliver support." OFF) -option(BASALT_MMAP_DELIVER "Build with system shared memory data deliver support." OFF) +# option(BASALT_TCP_DELIVER "Build with TCP data deliver support." OFF) +# option(BASALT_MMAP_DELIVER "Build with system shared memory data deliver support." OFF) # 3D Objects Loaders option(BASALT_OBJ_OBJECT_LOADER "Build with Wavefront OBJ 3D object loader support." OFF) option(BASALT_GLTF_OBJECT_LOADER "Build with glTF 3D object loader support." OFF) @@ -29,14 +32,20 @@ set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# Include some essential CMake components +include(GNUInstallDirs) + +# Import packages +# Find required packages based on options +if (BASALT_CUDA_DELIVER) + find_package(CUDA REQUIRED) +endif () +if (BASALT_DIRECTX11_ENGINE) + include(cmake/FindDirectX11.cmake) +endif () + + # Include projects add_subdirectory(Shared) add_subdirectory(Presenter) add_subdirectory(Plugins) - -# Add your executable or library targets here -# Example for an executable: -# add_executable(basalt main.cpp) - -# Example for a library: -# add_library(basalt src/basalt.cpp) \ No newline at end of file diff --git a/BasaltPresenter/Plugins/AnimeLoader/CMakeLists.txt b/BasaltPresenter/Plugins/AnimeLoader/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/BasaltPresenter/Plugins/CMakeLists.txt b/BasaltPresenter/Plugins/CMakeLists.txt index e69de29..4c2ac0f 100644 --- a/BasaltPresenter/Plugins/CMakeLists.txt +++ b/BasaltPresenter/Plugins/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(Engine) +add_subdirectory(Deliver) +add_subdirectory(ObjectLoader) +add_subdirectory(AnimeLoader) diff --git a/BasaltPresenter/Plugins/Deliver/CMakeLists.txt b/BasaltPresenter/Plugins/Deliver/CMakeLists.txt new file mode 100644 index 0000000..0519942 --- /dev/null +++ b/BasaltPresenter/Plugins/Deliver/CMakeLists.txt @@ -0,0 +1,5 @@ +# add_subdirectory(CudaDeliver) +# add_subdirectory(RocmDeliver) +add_subdirectory(PipeDeliver) +# add_subdirectory(TcpDeliver) +# add_subdirectory(MmapDeliver) diff --git a/BasaltPresenter/Plugins/Deliver/PipeDeliver/CMakeLists.txt b/BasaltPresenter/Plugins/Deliver/PipeDeliver/CMakeLists.txt new file mode 100644 index 0000000..aa81b9b --- /dev/null +++ b/BasaltPresenter/Plugins/Deliver/PipeDeliver/CMakeLists.txt @@ -0,0 +1,27 @@ +# Create shared library +add_library(PipeDeliver SHARED "") +# Setup sources +target_sources(PipeDeliver +PRIVATE + main.cpp +) +# Setup header infomation +target_include_directories(PipeDeliver +PRIVATE + "${CMAKE_CURRENT_LIST_DIR}" +) +# Setup linked library infomation +target_link_libraries(PipeDeliver +PRIVATE + BasaltShared +) +# Enable export macro +target_compile_definitions(PipeDeliver +PRIVATE + BS_EXPORTING +) + +# Install PipeDeliver only on Release mode +install(TARGETS PipeDeliver + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/plugins/engine" +) diff --git a/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp b/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp new file mode 100644 index 0000000..734b6b9 --- /dev/null +++ b/BasaltPresenter/Plugins/Deliver/PipeDeliver/main.cpp @@ -0,0 +1,9 @@ +#include + +BS_EXPORT void* BSCreateInstance() { + return nullptr; +} + +BS_EXPORT void BSDestroyInstance(void* instance) { + return; +} diff --git a/BasaltPresenter/Plugins/Engine/CMakeLists.txt b/BasaltPresenter/Plugins/Engine/CMakeLists.txt new file mode 100644 index 0000000..7112de5 --- /dev/null +++ b/BasaltPresenter/Plugins/Engine/CMakeLists.txt @@ -0,0 +1,6 @@ +# add_subdirectory(DirectX8Engine) +# add_subdirectory(DirectX9Engine) +add_subdirectory(DirectX11Engine) +# add_subdirectory(DirectX12Engine) +# add_subdirectory(OpenGLEngine) +# add_subdirectory(VulkanEngine) diff --git a/BasaltPresenter/Plugins/Engine/DirectX11Engine/CMakeLists.txt b/BasaltPresenter/Plugins/Engine/DirectX11Engine/CMakeLists.txt new file mode 100644 index 0000000..573c665 --- /dev/null +++ b/BasaltPresenter/Plugins/Engine/DirectX11Engine/CMakeLists.txt @@ -0,0 +1,27 @@ +# Create shared library +add_library(DirectX11Engine SHARED "") +# Setup sources +target_sources(DirectX11Engine +PRIVATE + main.cpp +) +# Setup header infomation +target_include_directories(DirectX11Engine +PRIVATE + "${CMAKE_CURRENT_LIST_DIR}" +) +# Setup linked library infomation +target_link_libraries(DirectX11Engine +PRIVATE + BasaltShared +) +# Enable export macro +target_compile_definitions(DirectX11Engine +PRIVATE + BS_EXPORTING +) + +# Install DirectX11Engine only on Release mode +install(TARGETS DirectX11Engine + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/plugins/engine" +) diff --git a/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp b/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp new file mode 100644 index 0000000..734b6b9 --- /dev/null +++ b/BasaltPresenter/Plugins/Engine/DirectX11Engine/main.cpp @@ -0,0 +1,9 @@ +#include + +BS_EXPORT void* BSCreateInstance() { + return nullptr; +} + +BS_EXPORT void BSDestroyInstance(void* instance) { + return; +} diff --git a/BasaltPresenter/Plugins/ObjectLoader/CMakeLists.txt b/BasaltPresenter/Plugins/ObjectLoader/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/BasaltPresenter/Presenter/dll_loader.hpp b/BasaltPresenter/Presenter/dll_loader.hpp index d012119..47ede80 100644 --- a/BasaltPresenter/Presenter/dll_loader.hpp +++ b/BasaltPresenter/Presenter/dll_loader.hpp @@ -10,10 +10,10 @@ namespace Basalt::Presenter { enum class DllKind { - RenderEngine, - DataDeliver, - ObjectLoader, - AnimationLoader, + Engine, ///< Render engine + Deliver, ///< Data deliver + ObjectLoader, ///< 3D object loader + AnimeLoader, ///< Camera animation loader }; class DllLoader { diff --git a/BasaltPresenter/Shared/CMakeLists.txt b/BasaltPresenter/Shared/CMakeLists.txt index a69604f..1227198 100644 --- a/BasaltPresenter/Shared/CMakeLists.txt +++ b/BasaltPresenter/Shared/CMakeLists.txt @@ -1,7 +1,10 @@ add_library(BasaltShared STATIC "") target_sources(BasaltShared PRIVATE + # Sources pipe_operator.cpp + engine.cpp + deliver.cpp ) target_sources(BasaltShared PUBLIC @@ -9,17 +12,16 @@ FILE_SET HEADERS FILES # Headers basalt_char.hpp + basalt_export.hpp pipe_operator.hpp + engine.hpp + deliver.hpp ) target_include_directories(BasaltShared PUBLIC "$" "$" ) -# target_link_libraries(BasaltShared -# PRIVATE -# BasaltShared -# ) target_compile_definitions(BasaltShared PUBLIC $<$:BASALT_OS_WINDOWS> diff --git a/BasaltPresenter/Shared/basalt_export.hpp b/BasaltPresenter/Shared/basalt_export.hpp new file mode 100644 index 0000000..1e3d5e2 --- /dev/null +++ b/BasaltPresenter/Shared/basalt_export.hpp @@ -0,0 +1,36 @@ +#pragma once + +// Reference: https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux +// Generate macro for import and export respectively. +#if defined(_MSC_VER) +// Microsoft +#define BS_RAW_EXPORT __declspec(dllexport) +#define BS_RAW_IMPORT __declspec(dllimport) +#elif defined(__GNUC__) +// GCC +#define BS_RAW_EXPORT __attribute__((visibility("default"))) +#define BS_RAW_IMPORT +#elif defined(__clang__) +// Clang +#define BS_RAW_EXPORT __attribute__((visibility("default"))) +#define BS_RAW_IMPORT +#else +// Do nothing and hope for the best? +#define BS_RAW_EXPORT +#define BS_RAW_IMPORT +#error "Unknown dynamic link import/export semantics." +#endif + +// Choosee import or export command according to special macro. +#if defined(BS_EXPORTING) +#define BS_NAKED_EXPORT BS_RAW_EXPORT +#else +#define BS_NAKED_EXPORT BS_RAW_IMPORT +#endif + +// Create real export macro according to whether in C++ environment. +#if defined(__cplusplus) +#define BS_EXPORT extern "C" BS_NAKED_EXPORT +#else +#define BS_EXPORT BS_NAKED_EXPORT +#endif diff --git a/BasaltPresenter/Shared/deliver.cpp b/BasaltPresenter/Shared/deliver.cpp new file mode 100644 index 0000000..90cfa94 --- /dev/null +++ b/BasaltPresenter/Shared/deliver.cpp @@ -0,0 +1,9 @@ +#include "deliver.hpp" + +namespace Basalt::Shared::Deliver { + + IDeliver::IDeliver() {} + + IDeliver::~IDeliver() {} + +} // namespace Basalt::Shared::Deliver diff --git a/BasaltPresenter/Shared/deliver.hpp b/BasaltPresenter/Shared/deliver.hpp new file mode 100644 index 0000000..dea56e3 --- /dev/null +++ b/BasaltPresenter/Shared/deliver.hpp @@ -0,0 +1,18 @@ +#pragma once + +namespace Basalt::Shared::Deliver { + + struct DeliverConfig { + + }; + + class IDeliver { + public: + IDeliver(); + virtual ~IDeliver(); + + public: + virtual void Transmit() = 0; + }; + +} diff --git a/BasaltPresenter/Shared/engine.cpp b/BasaltPresenter/Shared/engine.cpp new file mode 100644 index 0000000..8f238a4 --- /dev/null +++ b/BasaltPresenter/Shared/engine.cpp @@ -0,0 +1,9 @@ +#include "engine.hpp" + +namespace Basalt::Shared::Engine { + + IEngine::IEngine(EngineConfig&& config) : config(std::move(config)) {} + + IEngine::~IEngine() {} + +} // namespace Basalt::Shared::Engine diff --git a/BasaltPresenter/Shared/engine.hpp b/BasaltPresenter/Shared/engine.hpp new file mode 100644 index 0000000..625f564 --- /dev/null +++ b/BasaltPresenter/Shared/engine.hpp @@ -0,0 +1,36 @@ +#pragma once +#include "basalt_char.hpp" +#include +#include + +namespace Basalt::Shared::Engine { + + enum class EngineKind { + DirectX8, + DirectX9, + DirectX11, + DirectX12, + OpenGL, + Vulkan, + }; + + struct EngineConfig { + bool is_headless; ///< Whether enable headless mode (No Window created). + std::basic_string title; ///< Window title. + std::uint32_t width; ///< Window width. + std::uint32_t height; ///< Window height. + }; + + class IEngine { + public: + IEngine(EngineConfig&& config); + virtual ~IEngine(); + + public: + virtual void Tick() = 0; + + protected: + EngineConfig config; + }; + +}