Skip to content

Commit 5a6a8c3

Browse files
Update plume, bind correct depth attachment slice, and add Metal support. (#18)
* Update to upstream plume. * Bind correct depth attachment slice. * Support for Metal backend. Co-authored-by: Isaac Marovitz <isaacryu@icloud.com> --------- Co-authored-by: Isaac Marovitz <isaacryu@icloud.com>
1 parent a3f5100 commit 5a6a8c3

90 files changed

Lines changed: 1238 additions & 12082 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.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ FodyWeavers.xsd
397397

398398
# JetBrains Rider
399399
*.sln.iml
400+
.idea
400401

401402
# macOS metadata files
402403
.DS_Store

.gitmodules

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,9 @@
1313
[submodule "thirdparty/vcpkg"]
1414
path = thirdparty/vcpkg
1515
url = https://github.com/microsoft/vcpkg
16-
[submodule "thirdparty/volk"]
17-
path = thirdparty/volk
18-
url = https://github.com/zeux/volk
1916
[submodule "thirdparty/SDL"]
2017
path = thirdparty/SDL
2118
url = https://github.com/libsdl-org/SDL.git
22-
[submodule "thirdparty/Vulkan-Headers"]
23-
path = thirdparty/Vulkan-Headers
24-
url = https://github.com/KhronosGroup/Vulkan-Headers.git
25-
[submodule "thirdparty/VulkanMemoryAllocator"]
26-
path = thirdparty/VulkanMemoryAllocator
27-
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
28-
[submodule "thirdparty/D3D12MemoryAllocator"]
29-
path = thirdparty/D3D12MemoryAllocator
30-
url = https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git
3119
[submodule "thirdparty/stb"]
3220
path = thirdparty/stb
3321
url = https://github.com/nothings/stb.git
@@ -67,3 +55,6 @@
6755
[submodule "thirdparty/MoltenVK/SPIRV-Cross"]
6856
path = thirdparty/MoltenVK/SPIRV-Cross
6957
url = https://github.com/KhronosGroup/SPIRV-Cross.git
58+
[submodule "thirdparty/plume"]
59+
path = thirdparty/plume
60+
url = https://github.com/renderbag/plume

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
1919

2020
project("MarathonRecomp-ALL")
2121

22+
if (APPLE)
23+
enable_language(OBJC OBJCXX)
24+
endif()
25+
2226
if (CMAKE_OSX_ARCHITECTURES)
2327
set(MARATHON_RECOMP_ARCHITECTURE ${CMAKE_OSX_ARCHITECTURES})
2428
elseif(CMAKE_SYSTEM_PROCESSOR)

MarathonRecomp/CMakeLists.txt

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
project("MarathonRecomp")
22

33
if (WIN32)
4-
option(MARATHON_RECOMP_D3D12 "Add D3D12 support for rendering" OFF)
4+
option(MARATHON_RECOMP_D3D12 "Add D3D12 support for rendering" ON)
5+
endif()
6+
7+
if (APPLE)
8+
option(MARATHON_RECOMP_METAL "Add Metal support for rendering" ON)
59
endif()
610

711
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
@@ -116,15 +120,8 @@ set(MARATHON_RECOMP_GPU_CXX_SOURCES
116120
"gpu/imgui/imgui_common.cpp"
117121
"gpu/imgui/imgui_font_builder.cpp"
118122
"gpu/imgui/imgui_snapshot.cpp"
119-
"gpu/rhi/plume_vulkan.cpp"
120123
)
121124

122-
if (MARATHON_RECOMP_D3D12)
123-
list(APPEND MARATHON_RECOMP_GPU_CXX_SOURCES
124-
"gpu/rhi/plume_d3d12.cpp"
125-
)
126-
endif()
127-
128125
set(MARATHON_RECOMP_APU_CXX_SOURCES
129126
"apu/audio.cpp"
130127
"apu/xma_decoder.cpp"
@@ -225,18 +222,10 @@ set(MARATHON_RECOMP_THIRDPARTY_INCLUDES
225222
"${MARATHON_RECOMP_THIRDPARTY_ROOT}/magic_enum/include"
226223
"${MARATHON_RECOMP_THIRDPARTY_ROOT}/stb"
227224
"${MARATHON_RECOMP_THIRDPARTY_ROOT}/unordered_dense/include"
228-
"${MARATHON_RECOMP_THIRDPARTY_ROOT}/volk"
229-
"${MARATHON_RECOMP_THIRDPARTY_ROOT}/Vulkan-Headers/include"
230-
"${MARATHON_RECOMP_THIRDPARTY_ROOT}/VulkanMemoryAllocator/include"
231225
"${MARATHON_RECOMP_TOOLS_ROOT}/bc_diff"
232226
"${MARATHON_RECOMP_TOOLS_ROOT}/XenosRecomp/thirdparty/smol-v/source"
233227
)
234228

235-
if (MARATHON_RECOMP_D3D12)
236-
list(APPEND MARATHON_RECOMP_THIRDPARTY_INCLUDES "${MARATHON_RECOMP_THIRDPARTY_ROOT}/D3D12MemoryAllocator/include")
237-
list(APPEND MARATHON_RECOMP_THIRDPARTY_SOURCES "${MARATHON_RECOMP_THIRDPARTY_ROOT}/D3D12MemoryAllocator/src/D3D12MemAlloc.cpp")
238-
endif()
239-
240229
set_source_files_properties(${MARATHON_RECOMP_THIRDPARTY_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
241230

242231
set(MARATHON_RECOMP_CXX_SOURCES
@@ -274,6 +263,10 @@ if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
274263
set(SHOW_GIT_INFO_AND_BUILD_TYPE 1)
275264
endif()
276265

266+
if (MARATHON_RECOMP_METAL)
267+
set(XCRUN_TOOL "/usr/bin/xcrun")
268+
endif()
269+
277270
GenerateVersionSources(
278271
OUTPUT_DIR ${PROJECT_SOURCE_DIR}
279272
VERSION_TXT ${VERSION_TXT}
@@ -377,35 +370,35 @@ if (MARATHON_RECOMP_D3D12)
377370
target_compile_definitions(MarathonRecomp PRIVATE MARATHON_RECOMP_D3D12)
378371
endif()
379372

373+
if (MARATHON_RECOMP_METAL)
374+
target_compile_definitions(MarathonRecomp PRIVATE MARATHON_RECOMP_METAL)
375+
endif()
376+
380377
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
381378
target_compile_definitions(MarathonRecomp PRIVATE SDL_VULKAN_ENABLED)
382379
endif()
383380

384-
#find_package(directx-dxc REQUIRED)
385381
find_package(CURL REQUIRED)
386382

387-
#if (MARATHON_RECOMP_D3D12)
388-
# file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12)
389-
# add_custom_command(TARGET MarathonRecomp POST_BUILD
390-
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Core,IMPORTED_LOCATION_RELEASE> ${CMAKE_CURRENT_BINARY_DIR}/D3D12
391-
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Layers,IMPORTED_LOCATION_DEBUG> ${CMAKE_CURRENT_BINARY_DIR}/D3D12
392-
# COMMAND_EXPAND_LISTS
393-
# )
394-
#
395-
# find_file(DIRECTX_DXIL_LIBRARY "dxil.dll")
396-
# file(COPY ${DIRECTX_DXIL_LIBRARY} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
397-
#
398-
# target_link_libraries(MarathonRecomp PRIVATE
399-
# Microsoft::DirectX-Headers
400-
# Microsoft::DirectX-Guids
401-
# Microsoft::DirectX12-Agility
402-
# Microsoft::DirectXShaderCompiler
403-
# Microsoft::DXIL
404-
# dxgi
405-
# )
406-
#endif()
407-
408-
#file(CHMOD ${DIRECTX_DXC_TOOL} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE)
383+
if (MARATHON_RECOMP_D3D12)
384+
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/D3D12)
385+
add_custom_command(TARGET MarathonRecomp POST_BUILD
386+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Core,IMPORTED_LOCATION_RELEASE> $<TARGET_FILE_DIR:MarathonRecomp>/D3D12
387+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectX12-Layers,IMPORTED_LOCATION_DEBUG> $<TARGET_FILE_DIR:MarathonRecomp>/D3D12
388+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DirectXShaderCompiler,IMPORTED_LOCATION> $<TARGET_FILE_DIR:MarathonRecomp>
389+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PROPERTY:Microsoft::DXIL,IMPORTED_LOCATION> $<TARGET_FILE_DIR:MarathonRecomp>
390+
COMMAND_EXPAND_LISTS
391+
)
392+
393+
target_link_libraries(MarathonRecomp PRIVATE
394+
Microsoft::DirectX-Headers
395+
Microsoft::DirectX-Guids
396+
Microsoft::DirectX12-Agility
397+
Microsoft::DirectXShaderCompiler
398+
Microsoft::DXIL
399+
dxgi
400+
)
401+
endif()
409402

410403
if (WIN32)
411404
target_link_libraries(MarathonRecomp PRIVATE
@@ -432,6 +425,7 @@ target_link_libraries(MarathonRecomp PRIVATE
432425
MarathonRecompLib
433426
xxHash::xxhash
434427
CURL::libcurl
428+
plume
435429
)
436430

437431
if (NOT WIN32)
@@ -456,22 +450,37 @@ endif()
456450
target_precompile_headers(MarathonRecomp PUBLIC ${MARATHON_RECOMP_PRECOMPILED_HEADERS})
457451

458452
function(compile_shader FILE_PATH TARGET_NAME)
459-
set(FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/gpu/shader/${FILE_PATH}.hlsl)
460-
cmake_path(GET FILE_PATH STEM VARIABLE_NAME)
453+
set(HLSL_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/gpu/shader/hlsl/${FILE_PATH}.hlsl)
454+
set(MSL_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/gpu/shader/msl/${FILE_PATH}.metal)
455+
cmake_path(GET HLSL_FILE_PATH STEM HLSL_NAME)
456+
cmake_path(GET MSL_FILE_PATH STEM MSL_NAME)
457+
if (MARATHON_RECOMP_METAL)
458+
add_custom_command(
459+
OUTPUT ${MSL_FILE_PATH}.ir
460+
COMMAND ${XCRUN_TOOL} -sdk macosx metal -o ${MSL_FILE_PATH}.ir -c ${MSL_FILE_PATH} -D__air__ -frecord-sources -gline-tables-only
461+
DEPENDS ${MSL_FILE_PATH}
462+
)
463+
add_custom_command(
464+
OUTPUT ${MSL_FILE_PATH}.metallib
465+
COMMAND ${XCRUN_TOOL} -sdk macosx metallib -o ${MSL_FILE_PATH}.metallib ${MSL_FILE_PATH}.ir
466+
DEPENDS ${MSL_FILE_PATH}.ir
467+
)
468+
BIN2C(TARGET_OBJ MarathonRecomp SOURCE_FILE "${MSL_FILE_PATH}.metallib" DEST_FILE "${MSL_FILE_PATH}.metallib" ARRAY_NAME "g_${MSL_NAME}_air")
469+
endif()
461470
if (MARATHON_RECOMP_D3D12)
462471
add_custom_command(
463-
OUTPUT ${FILE_PATH}.dxil.h
464-
COMMAND ${DIRECTX_DXC_TOOL} -T ${TARGET_NAME} -HV 2021 -all-resources-bound -Wno-ignored-attributes -Fh ${FILE_PATH}.dxil.h ${FILE_PATH} -Vn g_${VARIABLE_NAME}_dxil
465-
DEPENDS ${FILE_PATH}
472+
OUTPUT ${HLSL_FILE_PATH}.dxil.h
473+
COMMAND ${DIRECTX_DXC_TOOL} -T ${TARGET_NAME} -HV 2021 -all-resources-bound -Wno-ignored-attributes -Fh ${HLSL_FILE_PATH}.dxil.h ${HLSL_FILE_PATH} -Vn g_${HLSL_NAME}_dxil
474+
DEPENDS ${HLSL_FILE_PATH}
466475
)
467-
target_sources(MarathonRecomp PRIVATE ${FILE_PATH}.dxil.h)
476+
target_sources(MarathonRecomp PRIVATE ${HLSL_FILE_PATH}.dxil.h)
468477
endif()
469478
add_custom_command(
470-
OUTPUT ${FILE_PATH}.spirv.h
471-
COMMAND ${DIRECTX_DXC_TOOL} -T ${TARGET_NAME} -HV 2021 -all-resources-bound -spirv -fvk-use-dx-layout ${ARGN} -Fh ${FILE_PATH}.spirv.h ${FILE_PATH} -Vn g_${VARIABLE_NAME}_spirv
472-
DEPENDS ${FILE_PATH}
479+
OUTPUT ${HLSL_FILE_PATH}.spirv.h
480+
COMMAND ${DIRECTX_DXC_TOOL} -T ${TARGET_NAME} -HV 2021 -all-resources-bound -spirv -fvk-use-dx-layout ${ARGN} -Fh ${HLSL_FILE_PATH}.spirv.h ${HLSL_FILE_PATH} -Vn g_${HLSL_NAME}_spirv
481+
DEPENDS ${HLSL_FILE_PATH}
473482
)
474-
target_sources(MarathonRecomp PRIVATE ${FILE_PATH}.spirv.h)
483+
target_sources(MarathonRecomp PRIVATE ${HLSL_FILE_PATH}.spirv.h)
475484
endfunction()
476485

477486
function(compile_vertex_shader FILE_PATH)

MarathonRecomp/gpu/imgui/imgui_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define IMGUI_SHADER_MODIFIER_RECTANGLE_BEVEL 7
1111
#define IMGUI_SHADER_MODIFIER_LOW_QUALITY_TEXT 8
1212

13-
#ifdef __cplusplus
13+
#if defined(__cplusplus) && !defined(__air__)
1414

1515
enum class ImGuiCallback : int32_t
1616
{

MarathonRecomp/gpu/rhi/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)