mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-09 13:36:35 +00:00
Bundle extra shaders ported from PPSSPP
This commit is contained in:
@@ -300,6 +300,18 @@ if (ENABLE_LSFG)
|
||||
endif()
|
||||
|
||||
if (ENABLE_RESHADE)
|
||||
set(BUNDLED_FX_DIR ${CMAKE_SOURCE_DIR}/dist/post_shaders)
|
||||
set(BUNDLED_FX_HEADER ${CMAKE_CURRENT_BINARY_DIR}/bundled_fx_effects.h)
|
||||
file(GLOB BUNDLED_FX_FILES ${BUNDLED_FX_DIR}/*.fx)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${BUNDLED_FX_HEADER}
|
||||
COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/post_processing/GenerateBundledEffects.cmake
|
||||
${BUNDLED_FX_DIR} ${BUNDLED_FX_HEADER}
|
||||
DEPENDS ${BUNDLED_FX_FILES}
|
||||
)
|
||||
|
||||
target_sources(video_core PRIVATE
|
||||
post_processing/fx_chain.cpp
|
||||
post_processing/fx_chain.h
|
||||
@@ -309,7 +321,9 @@ if (ENABLE_RESHADE)
|
||||
post_processing/fx_effect.h
|
||||
renderer_vulkan/present/post_process.cpp
|
||||
renderer_vulkan/present/post_process.h
|
||||
${BUNDLED_FX_HEADER}
|
||||
)
|
||||
target_include_directories(video_core PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_link_libraries(video_core PRIVATE reshadefx::reshadefx)
|
||||
target_compile_definitions(video_core PUBLIC HAS_RESHADE)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
set(EFFECT_DIR ${CMAKE_ARGV3})
|
||||
set(HEADER_FILE ${CMAKE_ARGV4})
|
||||
|
||||
file(GLOB EFFECT_FILES ${EFFECT_DIR}/*.fx)
|
||||
list(SORT EFFECT_FILES)
|
||||
|
||||
set(ENTRIES "")
|
||||
foreach(EFFECT_FILE IN LISTS EFFECT_FILES)
|
||||
get_filename_component(EFFECT_NAME ${EFFECT_FILE} NAME)
|
||||
file(READ ${EFFECT_FILE} EFFECT_BODY)
|
||||
|
||||
string(REGEX REPLACE ";" "{{SEMICOLON}}" EFFECT_BODY "${EFFECT_BODY}")
|
||||
string(REGEX REPLACE "\n" ";" EFFECT_BODY "${EFFECT_BODY}")
|
||||
|
||||
set(EFFECT_TEXT "")
|
||||
foreach(LINE IN LISTS EFFECT_BODY)
|
||||
string(CONCAT EFFECT_TEXT "${EFFECT_TEXT}" " R\"(${LINE}\n)\"\n")
|
||||
endforeach()
|
||||
string(REGEX REPLACE "{{SEMICOLON}}" ";" EFFECT_TEXT "${EFFECT_TEXT}")
|
||||
|
||||
string(CONCAT ENTRIES "${ENTRIES}"
|
||||
" {\n \"${EFFECT_NAME}\",\n${EFFECT_TEXT} },\n")
|
||||
endforeach()
|
||||
|
||||
get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY)
|
||||
make_directory(${OUTPUT_DIR})
|
||||
|
||||
file(WRITE ${HEADER_FILE}
|
||||
"// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace VideoCore {
|
||||
|
||||
struct BundledFxEffect {
|
||||
std::string_view name;
|
||||
std::string_view source;
|
||||
};
|
||||
|
||||
constexpr BundledFxEffect BUNDLED_FX_EFFECTS[]{
|
||||
${ENTRIES}};
|
||||
|
||||
} // namespace VideoCore
|
||||
")
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "bundled_fx_effects.h"
|
||||
#include "common/fs/file.h"
|
||||
#include "common/fs/fs.h"
|
||||
#include "common/fs/fs_util.h"
|
||||
#include "common/fs/path_util.h"
|
||||
@@ -228,11 +230,18 @@ void ReloadFxCatalog() {
|
||||
catalog_scanned = true;
|
||||
|
||||
const auto root = GetFxRootDirectory();
|
||||
if (!Common::FS::Exists(root)) {
|
||||
void(Common::FS::CreateDirs(root));
|
||||
if (!Common::FS::Exists(root) && !Common::FS::CreateDirs(root)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& bundled : BUNDLED_FX_EFFECTS) {
|
||||
const auto path = root / bundled.name;
|
||||
if (Common::FS::Exists(path)) {
|
||||
continue;
|
||||
}
|
||||
void(Common::FS::WriteStringToFile(path, Common::FS::FileType::TextFile, bundled.source));
|
||||
}
|
||||
|
||||
std::vector<std::filesystem::path> effect_files;
|
||||
Common::FS::IterateDirEntriesRecursively(
|
||||
root,
|
||||
|
||||
Reference in New Issue
Block a user