Remove shader cache and make it optional (#238)

This commit is contained in:
David Chavez 2024-05-22 10:55:54 +02:00 committed by GitHub
parent 26f5fcc952
commit 466b766cfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 7 deletions

View File

@ -87,11 +87,15 @@ add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/RecompiledPatches/patches_bin.c
DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.bin DEPENDS ${CMAKE_SOURCE_DIR}/patches/patches.bin
) )
# Generate mm_shader_cache.c from the MM shader cache # Generate mm_shader_cache.c from the MM shader cache if it exists
if (EXISTS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin)
set(HAS_MM_SHADER_CACHE TRUE)
add_compile_definitions(HAS_MM_SHADER_CACHE)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h
COMMAND file_to_c ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin mm_shader_cache_bytes ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h COMMAND file_to_c ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin mm_shader_cache_bytes ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.h
DEPENDS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin DEPENDS ${CMAKE_SOURCE_DIR}/shadercache/mm_shader_cache.bin
) )
endif()
# Recompile patches elf into patches.c # Recompile patches elf into patches.c
add_custom_command(OUTPUT add_custom_command(OUTPUT
@ -159,10 +163,12 @@ set (SOURCES
${CMAKE_SOURCE_DIR}/rsp/njpgdspMain.cpp ${CMAKE_SOURCE_DIR}/rsp/njpgdspMain.cpp
${CMAKE_SOURCE_DIR}/lib/RmlUi/Backends/RmlUi_Platform_SDL.cpp ${CMAKE_SOURCE_DIR}/lib/RmlUi/Backends/RmlUi_Platform_SDL.cpp
${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c
) )
if (HAS_MM_SHADER_CACHE)
list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/mm_shader_cache.c)
endif()
target_include_directories(Zelda64Recompiled PRIVATE target_include_directories(Zelda64Recompiled PRIVATE
${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/lib/concurrentqueue ${CMAKE_SOURCE_DIR}/lib/concurrentqueue

0
shadercache/.gitkeep Normal file
View File

Binary file not shown.

View File

@ -17,7 +17,9 @@
#include "xxHash/xxh3.h" #include "xxHash/xxh3.h"
#include "../ultramodern/ultramodern.hpp" #include "../ultramodern/ultramodern.hpp"
#include "../../RecompiledPatches/patches_bin.h" #include "../../RecompiledPatches/patches_bin.h"
#ifdef HAS_MM_SHADER_CACHE
#include "mm_shader_cache.h" #include "mm_shader_cache.h"
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
inline uint32_t byteswap(uint32_t val) { inline uint32_t byteswap(uint32_t val) {
@ -411,7 +413,11 @@ void recomp::start(ultramodern::WindowHandle window_handle, const ultramodern::a
if (!recomp::load_stored_rom(recomp::Game::MM)) { if (!recomp::load_stored_rom(recomp::Game::MM)) {
recomp::message_box("Error opening stored ROM! Please restart this program."); recomp::message_box("Error opening stored ROM! Please restart this program.");
} }
#ifdef HAS_MM_SHADER_CACHE
ultramodern::load_shader_cache({mm_shader_cache_bytes, sizeof(mm_shader_cache_bytes)}); ultramodern::load_shader_cache({mm_shader_cache_bytes, sizeof(mm_shader_cache_bytes)});
#endif
init(rdram, &context); init(rdram, &context);
try { try {
recomp_entrypoint(rdram, &context); recomp_entrypoint(rdram, &context);