From ce67db864b69fd96276f81b433f9fc3943b90c55 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 7 Mar 2025 13:37:17 -0800 Subject: [PATCH] Switch to renderbag dxc-bin for shader compiler. (#6) --- .gitmodules | 3 +++ CMakeLists.txt | 1 - XenosRecomp/CMakeLists.txt | 19 +++++++++++++------ thirdparty/CMakeLists.txt | 4 ++++ thirdparty/dxc-bin | 1 + vcpkg.json | 6 ------ 6 files changed, 21 insertions(+), 13 deletions(-) create mode 160000 thirdparty/dxc-bin delete mode 100644 vcpkg.json diff --git a/.gitmodules b/.gitmodules index 8401190..81dcbc8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "thirdparty/fmt"] path = thirdparty/fmt url = https://github.com/fmtlib/fmt.git +[submodule "thirdparty/dxc-bin"] + path = thirdparty/dxc-bin + url = https://github.com/renderbag/dxc-bin.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b6e3369..ad9a1db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ cmake_minimum_required(VERSION 3.20) -include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) set(CMAKE_CXX_STANDARD 17) project("XenosRecomp-ALL") diff --git a/XenosRecomp/CMakeLists.txt b/XenosRecomp/CMakeLists.txt index 4e0e2d2..e505a5e 100644 --- a/XenosRecomp/CMakeLists.txt +++ b/XenosRecomp/CMakeLists.txt @@ -18,11 +18,8 @@ add_executable(XenosRecomp shader_recompiler.h "${SMOLV_SOURCE_DIR}/smolv.cpp") -find_package(directx-dxc CONFIG REQUIRED) - target_link_libraries(XenosRecomp PRIVATE Microsoft::DirectXShaderCompiler - Microsoft::DXIL xxHash::xxhash libzstd_static fmt::fmt) @@ -31,16 +28,26 @@ target_include_directories(XenosRecomp PRIVATE ${SMOLV_SOURCE_DIR}) target_precompile_headers(XenosRecomp PRIVATE pch.h) -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") target_compile_options(XenosRecomp PRIVATE -Wno-switch -Wno-unused-variable -Wno-null-arithmetic -fms-extensions) + + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(_LIBCPP_VERSION version LIBCPP) + if(LIBCPP) + # Allows using std::execution + target_compile_options(XenosRecomp PRIVATE -fexperimental-library) + endif() endif() if (WIN32) target_compile_definitions(XenosRecomp PRIVATE _CRT_SECURE_NO_WARNINGS) - find_file(DIRECTX_DXIL_LIBRARY "dxil.dll") - file(COPY ${DIRECTX_DXIL_LIBRARY} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + add_custom_command(TARGET XenosRecomp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ + COMMAND_EXPAND_LISTS + ) endif() if (XENOS_RECOMP_DXIL) target_compile_definitions(XenosRecomp PRIVATE XENOS_RECOMP_DXIL) + target_link_libraries(XenosRecomp PRIVATE Microsoft::DXIL) endif() diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 1418b7a..420195d 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -9,3 +9,7 @@ endif() if (NOT TARGET libzstd) add_subdirectory("${XENOS_RECOMP_THIRDPARTY_ROOT}/zstd/build/cmake") endif() + +if (NOT TARGET Microsoft::DirectXShaderCompiler) + add_subdirectory("${XENOS_RECOMP_THIRDPARTY_ROOT}/dxc-bin") +endif() diff --git a/thirdparty/dxc-bin b/thirdparty/dxc-bin new file mode 160000 index 0000000..737ac9f --- /dev/null +++ b/thirdparty/dxc-bin @@ -0,0 +1 @@ +Subproject commit 737ac9f51c3d06f0cd1ee7e14dc065bafd52310d diff --git a/vcpkg.json b/vcpkg.json deleted file mode 100644 index 1a3a8f0..0000000 --- a/vcpkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "builtin-baseline": "b322364f06308bdd24823f9d8f03fe0cc86fd46f", - "dependencies": [ - "directx-dxc" - ] -}