From 8e8ce8b42ff8ae156f0f6fa44039d2e7386fe312 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Thu, 17 Oct 2024 01:04:21 +0300 Subject: [PATCH] Use vcpkg for dependencies. --- .gitmodules | 19 -------- CMakeLists.txt | 3 +- CMakeSettings.json | 66 +++++++++++++++----------- UnleashedRecomp/CMakeLists.txt | 38 +++++++++------ UnleashedRecomp/gpu/rhi/rt64_d3d12.cpp | 4 +- thirdparty/CMakeLists.txt | 2 - thirdparty/D3D12MemoryAllocator | 1 - thirdparty/SDL | 1 - thirdparty/Vulkan-Headers | 1 - thirdparty/VulkanMemoryAllocator | 1 - thirdparty/unordered_dense | 1 - thirdparty/volk | 1 - vcpkg.json | 12 +++++ 13 files changed, 76 insertions(+), 74 deletions(-) delete mode 160000 thirdparty/D3D12MemoryAllocator delete mode 160000 thirdparty/SDL delete mode 160000 thirdparty/Vulkan-Headers delete mode 160000 thirdparty/VulkanMemoryAllocator delete mode 160000 thirdparty/unordered_dense delete mode 160000 thirdparty/volk create mode 100644 vcpkg.json diff --git a/.gitmodules b/.gitmodules index 7071c72e..d63944f7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,25 +1,6 @@ [submodule "thirdparty/PowerRecomp"] path = thirdparty/PowerRecomp url = https://github.com/hedge-dev/PowerRecomp -[submodule "thirdparty/SDL"] - path = thirdparty/SDL - url = https://github.com/libsdl-org/SDL.git - branch = SDL2 -[submodule "thirdparty/unordered_dense"] - path = thirdparty/unordered_dense - url = https://github.com/martinus/unordered_dense.git -[submodule "thirdparty/D3D12MemoryAllocator"] - path = thirdparty/D3D12MemoryAllocator - url = https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git [submodule "thirdparty/ddspp"] path = thirdparty/ddspp url = https://github.com/redorav/ddspp.git -[submodule "thirdparty/Vulkan-Headers"] - path = thirdparty/Vulkan-Headers - url = https://github.com/KhronosGroup/Vulkan-Headers -[submodule "thirdparty/VulkanMemoryAllocator"] - path = thirdparty/VulkanMemoryAllocator - url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git -[submodule "thirdparty/volk"] - path = thirdparty/volk - url = https://github.com/zeux/volk.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 3949dc8c..39f05a07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 3.20) +include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) set(SWA_THIRDPARTY_ROOT ${CMAKE_SOURCE_DIR}/thirdparty) set(CMAKE_CXX_STANDARD 23) set(BUILD_SHARED_LIBS OFF) @@ -12,8 +13,6 @@ endif() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(SDL_STATIC ON) - add_subdirectory(${SWA_THIRDPARTY_ROOT}) project("UnleashedRecomp-ALL") diff --git a/CMakeSettings.json b/CMakeSettings.json index 35574a29..0827846c 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,28 +1,40 @@ { - "configurations": [ - { - "name": "x64-Clang-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "clang_cl_x64_x64" ], - "variables": [] - }, - { - "name": "x64-Clang-Release", - "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "clang_cl_x64_x64" ], - "variables": [] - } - ] -} + "configurations": [ + { + "name": "x64-Clang-Debug", + "generator": "Ninja", + "configurationType": "Debug", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "clang_cl_x64_x64" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x64-windows-static", + "type": "STRING" + } + ] + }, + { + "name": "x64-Clang-Release", + "generator": "Ninja", + "configurationType": "RelWithDebInfo", + "buildRoot": "${projectDir}\\out\\build\\${name}", + "installRoot": "${projectDir}\\out\\install\\${name}", + "cmakeCommandArgs": "", + "buildCommandArgs": "", + "ctestCommandArgs": "", + "inheritEnvironments": [ "clang_cl_x64_x64" ], + "variables": [ + { + "name": "VCPKG_TARGET_TRIPLET", + "value": "x64-windows-static", + "type": "STRING" + } + ] + } + ] +} \ No newline at end of file diff --git a/UnleashedRecomp/CMakeLists.txt b/UnleashedRecomp/CMakeLists.txt index 6102f310..e1237cf1 100644 --- a/UnleashedRecomp/CMakeLists.txt +++ b/UnleashedRecomp/CMakeLists.txt @@ -56,28 +56,36 @@ set(SWA_CXX_SOURCES add_executable(UnleashedRecomp ${SWA_CXX_SOURCES}) set_target_properties(UnleashedRecomp PROPERTIES OUTPUT_NAME ${TARGET_NAME}) -target_link_libraries(UnleashedRecomp PUBLIC - UnleashedRecompLib - PowerUtils - o1heap - xxHash::xxhash - unordered_dense::unordered_dense - SDL2::SDL2-static - winmm - ntdll +find_package(d3d12-memory-allocator CONFIG REQUIRED) +find_package(SDL2 CONFIG REQUIRED) +find_package(unordered_dense CONFIG REQUIRED) +find_package(VulkanHeaders CONFIG) +find_package(volk CONFIG REQUIRED) +find_package(VulkanMemoryAllocator CONFIG REQUIRED) +find_package(xxHash CONFIG REQUIRED) + +target_link_libraries(UnleashedRecomp PRIVATE comctl32 d3d12 dxgi + Vulkan::Headers + volk::volk + volk::volk_headers + GPUOpen::VulkanMemoryAllocator + ntdll + o1heap + PowerUtils + SDL2::SDL2-static + UnleashedRecompLib + unofficial::D3D12MemoryAllocator + unordered_dense::unordered_dense + winmm + xxHash::xxhash ) + target_include_directories(UnleashedRecomp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${SWA_THIRDPARTY_ROOT}/ddspp - ${SWA_THIRDPARTY_ROOT}/D3D12MemoryAllocator/include - ${SWA_THIRDPARTY_ROOT}/D3D12MemoryAllocator/src - ${SWA_THIRDPARTY_ROOT}/volk - ${SWA_THIRDPARTY_ROOT}/Vulkan-Headers/include - ${SWA_THIRDPARTY_ROOT}/VulkanMemoryAllocator/include - ${SWA_THIRDPARTY_ROOT}/VulkanMemoryAllocator/src ) target_precompile_headers(UnleashedRecomp PUBLIC ${SWA_PRECOMPILED_HEADERS}) diff --git a/UnleashedRecomp/gpu/rhi/rt64_d3d12.cpp b/UnleashedRecomp/gpu/rhi/rt64_d3d12.cpp index 0a7b1e24..8b43fad4 100644 --- a/UnleashedRecomp/gpu/rhi/rt64_d3d12.cpp +++ b/UnleashedRecomp/gpu/rhi/rt64_d3d12.cpp @@ -12,8 +12,6 @@ #pragma clang diagnostic ignored "-Wswitch" #endif -#include "D3D12MemAlloc.cpp" - #ifdef __clang__ #pragma clang diagnostic pop #endif @@ -3307,7 +3305,7 @@ namespace RT64 { D3D12MA::ALLOCATOR_DESC allocatorDesc = {}; allocatorDesc.pDevice = d3d; allocatorDesc.pAdapter = adapter; - allocatorDesc.Flags = D3D12MA::ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED | D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED | D3D12MA::ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED; + allocatorDesc.Flags = D3D12MA::ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED | D3D12MA::ALLOCATOR_FLAG_MSAA_TEXTURES_ALWAYS_COMMITTED; res = D3D12MA::CreateAllocator(&allocatorDesc, &allocator); if (FAILED(res)) { diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 14c5d9bf..07a10b86 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,4 +1,2 @@ -add_subdirectory(${SWA_THIRDPARTY_ROOT}/unordered_dense) add_subdirectory(${SWA_THIRDPARTY_ROOT}/PowerRecomp) add_subdirectory(${SWA_THIRDPARTY_ROOT}/o1heap) -add_subdirectory(${SWA_THIRDPARTY_ROOT}/SDL) diff --git a/thirdparty/D3D12MemoryAllocator b/thirdparty/D3D12MemoryAllocator deleted file mode 160000 index e00c4a7c..00000000 --- a/thirdparty/D3D12MemoryAllocator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e00c4a7c85cf9c28c6f4a6cc75032736f416410f diff --git a/thirdparty/SDL b/thirdparty/SDL deleted file mode 160000 index 1edaad17..00000000 --- a/thirdparty/SDL +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1edaad17218d67b567c149badce9ef0fc67f65fa diff --git a/thirdparty/Vulkan-Headers b/thirdparty/Vulkan-Headers deleted file mode 160000 index 14345dab..00000000 --- a/thirdparty/Vulkan-Headers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 14345dab231912ee9601136e96ca67a6e1f632e7 diff --git a/thirdparty/VulkanMemoryAllocator b/thirdparty/VulkanMemoryAllocator deleted file mode 160000 index 1c35ba99..00000000 --- a/thirdparty/VulkanMemoryAllocator +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1c35ba99ce775f8342d87a83a3f0f696f99c2a39 diff --git a/thirdparty/unordered_dense b/thirdparty/unordered_dense deleted file mode 160000 index d911053e..00000000 --- a/thirdparty/unordered_dense +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d911053e390816ecc5dedd5a9d6b4bb5ed92b4c9 diff --git a/thirdparty/volk b/thirdparty/volk deleted file mode 160000 index 447e21b5..00000000 --- a/thirdparty/volk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 447e21b5d92ed8d5271b0d39b071f938fcfa875f diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..65da093b --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,12 @@ +{ + "builtin-baseline": "e63bd09dc0b7204467705c1c7c71d0e2a3f8860b", + "dependencies": [ + "d3d12-memory-allocator", + "sdl2", + "unordered-dense", + "volk", + "vulkan-headers", + "vulkan-memory-allocator", + "xxhash" + ] +}